Question

I'm using 'messi' Jquery notification plugin , in Login.aspx , if user is not Registered then a message is shown to user and redirect him to Register.aspx:

 ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), "    <script>alert('this is a message');window.location.href='Register.aspx';</script>", true);

this code works fine and I should click on OK button then page will be redirected, but when I use Messi.alert() instead of alert() , the message appears just for a second and then redirection is done automatically. I need to use this plugin what should I do?

Was it helpful?

Solution

You have to use callback in this case. E.g. Define you function in your JavaScript code as:

function alertRedirect(message, url) {
  new Messi(message, {title: 'Warning', 
                      modal: true, 
                      buttons: [{id: 0, label: 'OK', val: 'OK'}],
                      callback: function() {
      location.href = url;
  }});
}

And call it in your .net Code:

ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), "alertRedirect('this is a message','Register.aspx');", true);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top