Default button fired instead of focused button in asp.net - asp.net

Aspx page contains a panel having a default button called btnFilter. Panel having another button btnReset. When my focus is inside panel & I press enter its fires btnFilter click event that is OK. But first I put focus on reset button & then press enter it fires btnFilter click event instead of firing btnReset click event.
Is there any solution for this?

Related

Foundation fire event on modal popup

I use a modal of foundation(http://foundation.zurb.com/docs/components/reveal.html)
now I have a button inside the modal and I want to fire event when user press on the button.
but the event don't fire..
someone can help me?!
I find the soulation:
define LinkButton insead Button:

modal popup appears on screen on click of every usercontrol

I have multiple usercontrols in my home.aspx page.In the Header.ascx I have button imgbtnCreateAccount,On Click of this button modal popup appears on screen.
Now apart from this I have Product search User control ProductSearch.ascx.I am retrieving data from database for both the usercontrols. In producdtsearch.ascx page I have label, textbox and submit button.
If I leave textbox blank and press enter,it gives me required field validator which is fine,but when I type something in textbox and press enter it gives me modal popup which should not happen.It appears for all the other usercontrols which is textboxes in it.I have tried adding default button to the panel in which modal popup appears,but still nogo.Also tried changing the text property of imgbtnCreateAccount,still no go.
I also tried to set tetbox property to autopostback=true,but what haapens is that, the background of modal popup blinks for a second and then goes off. Modal popup should only appear on click of imgbtnCreateAccont which is Header.ascx page and nwhile entering tect in any of the textboxes of other usercontrols.Kindly suggest the resolution.
Issue got resolved as i added panel and inside the panel i have div which contains table.there is button in table.i have set the default button property of panel to this button name and the issue got resolved.

ModalPopupExtender OnShow Event

When clicking a button, I have a ModalPopupExtender (Panel) that gets displayed. I can't seem to trigger any event during that process.
Adding an event to the button that opens the ModalPopupExtender doesnt work, as it never triggers. Adding the button as a trigger in my UpdatePanel also doesnt work.
Scenario: I have a gridview with a button outside of the gridview. Clicking the button opens up a ModalPopupExtender which needs to display the checkboxes clicked on the gridview. I have the code to get the checkboxes clicked on the Gridview, however I cant seem to use an event during the process of opening the ModalPopupExtender.

determining that a Postback opens a new page

I have a page (page1) with a LinkButton that, when clicked, will take the browser to a new page (page2).
When I click the LinkButton page1 posts back and hits the Init and Load event handlers for page1, and then moves on to page2.
How can I tell in the page1 postback that I am about to be taken to a new page, as opposed to clicking a Button that causes the page posts back but does not navigate away?
You can also add OnClick events to your code behind for each button, and in the case of the one that is to postback to another page, do a Response.Redirect. The limitation of that however is that if you need form data on "page2", you will lose posted form data on a Response.Redirect.
It appears that you're not using the OnCLick event of the LinkButton, If you use the event, perform the action of the click there, not on the Page Load event?

calling __dopPostback from javascript where target control is an ASP.Net custom control

I need to pop up a jquery dialog as confirmation before a submit happens. I don't want the dialog to always pop up, that depends upon the setting of a dropdown.
The submitting control (which I can't change by the way) is a custom control with a save and a cancel button and handlers for the save and cancel buttons.
So when the user has selected a particular item from the drop down I hook up the click event (on the clientside) of the save button (that has been rendered by the custom control) to a js function using jQuery, that calls my showDialog() function and then returns false (to prevent the postback).
I now need, when the user clicks the yes button on the dialog, to call __doPostBack to get the SaveButtons serverside events to fire and to get the serverrside validation to run.
I've got
eval($("#<%= hdnBtnPostback.ClientID %>").val());
in the handler for the Yes button on the dialog.
The hdnPostBack field contains the result of:
Page.ClientScript.GetPostBackEventReference(mySaveCancelCustomControl, String.Empty)
Unsuprisingly this isn't working. The mySaveCancelCustomControl is the custom control mentioned above and it has two buttons that are rendered with two event handlers so the GetPostBackEventReference is doomed to fail.
Any ideas what I should do?
You can make the button a dialog button and put a asp.net button on the page with the ID of HiddenButton and wrap it in a div with a style of display:none; so the button is not visible. (Must not be Visible="false" so the button is rendered)
In the dialog javascript add a button that has the effect of clicking the hidden button
jQuery("#dialog").dialog({
buttons: {
'ButtonText': function() {
__doPostBack('<%# HiddenButton.ClientID %>', '')
jQuery(this).dialog('close');
}
}
});
and add a asp click handler to the hidden button
<div style="display:none;">
<asp:Button ID="HiddenButton" OnClick="HiddenButton_Click" ></Button>
<div>
Click event (HiddenButton_Click) on the serverside will fire when the dialog button is clicked
Hope this helps I use this pattern all the time
ps If ClientID does not work in the __doPostback() call user UniqueID I cant remember which it is.
When you are wiring up your new click on the client side, could you save the current click method into a temporary variable and then call the temporary variable from your Yes button?

Resources