Question

What I have is a popup defined within a user control, that is opened within a taskbar user control, which is attached to a master page, such that:

MasterPage.TaskBarUC.PopupUC

Within the popup, there are two buttons, one to save what the user is trying to do within a database, and one to cancel. I have some codebehind that does the work when the user clicks either button.

So every page has the taskbar, and they can click a button on the taskbar to access the popup and save the information. It works perfectly. However, there is one specific page within the site that needs to access the same popup from a button located on the page, as well as from the taskbar.

The button works, and it opens the popup, but for some reason, and only in this case, the "Save" button doesn't activate my codebehind. It DOES perform the validation that I have it do though. What is also weird is that the cancel button, which also activates some codebehind, does do what its supposed to.

I tried putting a breakpoint right at the beginning of my "Save" event handler, and it never reaches it. Its as if the button is only validating, and completely ignoring its OnClick event.

.aspx

<asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" 
    ValidationGroup="Validation" />
Était-ce utile?

La solution

I guess what happens is that the validation process has failed, which cancel the handling of the Button.Click event.

To check this possibility try to set the value of the Button.CausesValidation property to false and see if the Button.Click handling is going to continue or not.

Autres conseils

Button.CausesValidation property to false worked for me. I am using required field validator for different button. I think this could stop post back even for all other button click events (serverside).

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top