1

I'm using jqueryui dialog function to display my registration form. I have no problem with opening the dialog and displaying register.aspx file in the div. However I have a register button which I would like to use to save the form data into the database. But when I click to that button, it closes the dialog box and redirects the page to the register.aspx. I tried to disable usesubmitbehavior but that didn't help it completely blocks the function of the button.

<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" UseSubmitBehavior="False" />

protected void Button1_Click(object sender, EventArgs e)
    {
        firstName.Disabled = true; // this will be replaced for db data entry. It was just to see if the function is working or not.
    }

1 Answer 1

1

Use OnClientClick to prevent the default behaviour of form submission upon click. If you do this you will need perform an ajax request to your server yourself.

<asp:Button ID="Button1" OnClientClick="handleRegistrationClientSide(); return false;" runat="server" Text="Button" UseSubmitBehavior="False"  />

Otherwise wrap your dialog's inner content in an update panel, and trigger it on the button to cause an async postback.

<div id="myDialog">
    <asp:UpdatePanel runat="server">
       <ContentTemplate>
        ...
       </ContentTemplate>
       <Triggers>
          <asp:AsyncPostBackTrigger ControlID="Button1" />
       </Triggers>
    </asp:UpdatePanel>
</div>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.