To write a Script in server side in Asp.net

Labels: ,

Syntax :

ScriptManager.RegisterStartupScript(Control control,type type,string Key,string Script,bool addScriptTags)

Example:

string s = "alert('Hello')";

ScriptManager.RegisterStartupScript(this, this.GetType(), "Hello", s, true);

If you give the script tag in the string s then give addScriptTags to false.

ScriptManager is a class inside System.Web.UI

As a result a alert box with 'hello' pops up, where you place this line.

0 comments:

Post a Comment