“ClientScript'这个名字并不在目前的情况下存在 [英] The name 'ClientScript' does not exist in the current context
本文介绍了“ClientScript'这个名字并不在目前的情况下存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个背后code的JavaScript。它是表示一个JavaScript对话框。
但是,保持显示此错误
'ClientScript'这个名字并不在目前的情况下存在
这code的把里面的母版。我也用完全相同的code。在其他aspx文件,并从这个工作了天晴..
这是我的code:
保护无效Button2_Click(对象发件人,EventArgs的发送)
{
字符串消息=订单放置成功。
System.Text.StringBuilder SB =新System.Text.StringBuilder();
sb.Append(<脚本类型=文/ JavaScript的'>中);
sb.Append(在window.onload =函数(){);
sb.Append(警报(');
sb.Append(消息);
sb.Append(')};);
sb.Append(&下; /脚本>中);
ClientScript.RegisterClientScriptBlock(this.GetType(),警戒,sb.ToString());字符串脚本=警报('ABC');; }
解决方案
尝试:
Page.ClientScript
代替,看它是否有差别。
I have a behindcode javascript. it is to show a javascript dialog box.
however, it keep show this error
The name 'ClientScript' does not exist in the current context
This code was put inside masterpage. I had also use the exactly same code at other aspx file, and it work out fine apart from this..
here is my code:
protected void Button2_Click(object sender, EventArgs e)
{
string message = "Order Placed Successfully.";
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("<script type = 'text/javascript'>");
sb.Append("window.onload=function(){");
sb.Append("alert('");
sb.Append(message);
sb.Append("')};");
sb.Append("</script>");
ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", sb.ToString()); string script = "alert('abc');";
}
解决方案
Try:
Page.ClientScript
instead to see if it makes a difference.
这篇关于“ClientScript'这个名字并不在目前的情况下存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文