Display a javascript message box in asp.net application

Hi,
Display JavaScript Message box, which is created dynamically in the code behind

To display a message you can put the following code any where in the code behind page.
you must place only in between any functions.

Code
ClientScriptManager cs = Page.ClientScript;
Type ty = this.GetType();
cs.RegisterStartupScript(Type type, string key, string script,bool addScripttag);


ex : cs.RegisterStartupScript(ty, "Key Value", "alert('message')", true);

Enjoy this code to execute any type of javascript code
i check for this only.
You can check with other javascript code with this.

Thank You.


Comments

Author: VMRK29 Jul 2009 Member Level: Gold   Points : 0

good one really interesting

Author: Hari Nagaraj19 Aug 2009 Member Level: Bronze   Points : 1

As i want to display the message box with yes or no button in it.
If Yes is clicked want to execute some
similarly when No is clicked.
can any have the solution regarding this....

Author: Deepa28 Nov 2009 Member Level: Bronze   Points : 1

Hari

Which Message box you want to display?

Web Form or Windows Form

reply

Author: Deepa28 Nov 2009 Member Level: Bronze   Points : 1

strMsg=confirm('Do you want to delete record?');
if(strMsg)
{
//Condition of true Part
}
else
return false;


if value true comes ,true part will be executed.Otherwise false part will be executed.

Author: chrisy04 May 2010 Member Level: Bronze   Points : 1

ClientScriptManager cs = Page.ClientScript;
Type ty = this.GetType();
string script="var ans=confirm('Do you want to delete record?');
if(ans){__doPostback('button'1);}elsereturn false;";
cs.RegisterStartupScript(Type type, string key, string script,bool addScripttag);



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: