1

I am developing a website in which I am trying to display messages through ClientScript.RegisterStartUpScript.

This one was displayed successfully:

ClientScript.RegisterStartupScript(this.GetType(), "myalert", 
  "alert('All questions have been visited !');", true);

Although it gave a message with a checkbox saying "Prevent this page from creating additional dialogs".I did not check the checkbox. In my code behind I have this condition:

if (lblUnConfirmedQuestions.Text=="0")
{
}
else
{
    ClientScript.RegisterStartupScript(this.GetType(), "msg", 
     "alert( 'Please attempt all the questions !')",true);         
}

This one was supposed to be displayed later but it did not appear.

On the internet I found a suggestion to remove single quotes from the ClientScript message ,I removed them but still no success could be achieved.What should I do to display the second clientscript message?

TVicky
  • 353
  • 3
  • 13
  • 36
  • Why are you using RegisterStartupScript to display popups. Instead, this should be used to load a generic library and then you call a method in that library from your code. – ChrisBint Aug 26 '14 at 13:56

1 Answers1

1

"Please attempt all the questions !" is just text.

You need something like this in order to display alert message.

ClientScript.RegisterStartupScript(this.GetType(), 
    "msg", "alert('Please attempt all the questions !');",true);    
Win
  • 61,100
  • 13
  • 102
  • 181
  • Sorry! That was an editing mistake from my side.I have corrected it now.I actually used alert as well. – TVicky Aug 26 '14 at 14:04
  • @TVicky Set a break point at **if statement**, and debug it. Other than that, your code should be working. If you use Ajax, look at [this answer](http://stackoverflow.com/a/20149916/296861). – Win Aug 26 '14 at 14:22
  • @TVicky Your updated codes is working fine. However, if there is a Javascript error in other code, above code will stop working too. ***How to debug*** : create an ASPX page without Master Page, copy the above code, and debug it. – Win Aug 27 '14 at 13:48