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
Niradhip ChakrabortyPosted May 29, 2009, 1:26 PM
code for aspx page:
code for pagebehond:
private void OkayAction_Click1(object sender, System.EventArgs e)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "", "AlertMessage();", true);
}
Kirtan PatelPosted May 29, 2009, 10:23 AM
Button1_Click ...
{
Label l1 = new Label();
l1.Text = "";
Page.Controls.Add(l1);
}
Mohit JainPosted May 29, 2009, 9:33 AM
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.