eran otzap
eran otzap

Reputation: 12533

Jquery Ui-Dialog confirm form submit

i got an .aspx page when i press a button "submit" and all validation's pass the code behind is processed , when it's done i wan't to use the ui-dialog the confirm that notion to the user .

when the user presses ok i wan't the page to redirect back to the main page(different .aspx)

my question's are :

  1. is it even possible to redirect to an .aspx from the client side (i'm guessing not ..)

  2. if not how would i call the ui-dialog from the aspx page .

  3. how would i detect a post back using jquery ?

  4. how would i pull the query string using jquery ?

Upvotes: 0

Views: 657

Answers (1)

IUnknown
IUnknown

Reputation: 22478

You can call function for show message from code-behind. And yes, it's possible to redirect to an .aspx page from client side. Look at code below:

Javascript:

function showSuccessMessage() {
     $("#dialog-message").dialog({
          modal: true,
          buttons: {
               Ok: function () {
                    $(this).dialog("close");
                    window.location = '<%= ResolveClientUrl("~/Default.aspx") %>';
               }
          }
     });
}

All that you need is inject this function call in server code:

void SubmitButton_Click(object sender, EventArgs e)
{

    // your code here...

    if (IsAsync)
    {
        ScriptManager.RegisterStartupScript(this, this.GetType(), "success", "showSuccessMessage();", true);
    }
    else
    {
        ClientScript.RegisterStartupScript(this.GetType(), "success", "showSuccessMessage();", true);
    }
}

Upvotes: 1

Related Questions