Reputation: 18257
i'm my code behind of my web application, i have this method associated to the event click
protected void Button1_Click(object sender, EventArgs e)
{
string pagFinal = "this is a test";
ClientScript.RegisterClientScriptBlock(this.GetType(), "variable", "<script language=javascript> var direction = <%=pagFinal%> </script>");
}
but when i see the html generated doesn't appear's the javascript why i'm doing wrong. Thanks
Upvotes: 1
Views: 553
Reputation: 55519
You can directly replace the variable value in your code -
ClientScript.RegisterClientScriptBlock(this.GetType(), "variable", "<script language=javascript> var direction = '" + pagFinal + "'; </script>");
Upvotes: 6