whn i use this code it works
private void OkayAction_Click1(object sender, System.EventArgs e)
{
String message = Resources.ValidationResources.blank;
String script = "alert('message')";
ClientScript.RegisterClientScriptBlock(typeof(Page), "MyScript", script, true);
}
but this code doesnt work
private void OkayAction_Click1(object sender, System.EventArgs e)
{
String message = "hi";
String script = "alert(message)";
ClientScript.RegisterClientScriptBlock(typeof(Page), "MyScript", script, true);
}
means i have to pick up value ant other method to do ths plz
Loading

Mohit Jain19 reputationPosted May 29, 2009, 5:33 AM EDT
It is expected that the second code will not work as in second code you have removed the single quotes and when it is written on the page it becomes local variable for JavaScript which does not exist. So if you want to run the second code then Message varaibel should exist in JavaScript.
Kirtan PatelRank #292 · 8.6K reputationPosted May 29, 2009, 6:23 AM EDT
Button1_Click ...
{
Label l1 = new Label();
l1.Text = "";
Page.Controls.Add(l1);
}
Niradhip ChakrabortyRank #429 · 5.8K reputationPosted May 29, 2009, 9:26 AM EDT
code for aspx page:
code for pagebehond:
private void OkayAction_Click1(object sender, System.EventArgs e)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "", "AlertMessage();", true);
}