只能问.net高手了,Page.RegisterClientScriptBlock已过时

来源:百度知道 编辑:UC知道 时间:2024/06/23 23:09:43
.net2.0项目生成的时候出现警告:
E:\zhswNet\tupian.ascx.cs(53,9): 警告 CS0618: “System.Web.UI.Page.RegisterClientScriptBlock(string, string)”已过时:“The recommended alternative is ClientScript.RegisterClientScriptBlock(Type type, string key, string script). http://go.microsoft.com/fwlink/?linkid=14202

说Page.RegisterClientScriptBlock已过时,既然过时那有什么新的不过时的实现同样功能的代码吗?怎么样避免出现这个警告?

警告“System.Web.UI.Page.RegisterClientScriptBlock(string, string)”已过时:“The recommended alternative is ClientScript.RegisterClientScriptBlock(Type type, string key, string script). http://go.microsoft.com/fwlink/?linkid=14202
如果出现类似的警告,则应该这样处理:
如你的警告代码为:
RegisterClientScriptBlock("", "<script language=javascript>window.open('../Issue/IssueAllComment.aspx')</script>");
目的是要新弹出页面。
可以改为:
ClientScript.RegisterStartupScript(this.GetType(), "", "<script>window.open('../Issue/IssueAllComment.aspx');</script>");