我是我的Web应用程序背后的代码,我将此方法与事件相关联单击
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>");
}
但是当我看到生成的html没有出现时,javascript为什么我做错了。感谢
答案 0 :(得分:6)
您可以直接替换代码中的变量值 -
ClientScript.RegisterClientScriptBlock(this.GetType(), "variable", "<script language=javascript> var direction = '" + pagFinal + "'; </script>");