在我的web应用程序中,当我上传视频并单击保存按钮时,如果视频已上传,我会编写代码来显示消息video is uploaded。我的代码如下:
ClientScript.RegisterClientScriptBlock(GetType(), "sas", "<script> alert('Inserted successfully');</script>", false);当警告框出现时,它的背景是白色的。我点击了警告框中的确定按钮,但页面不会返回到前一页,它显示的是相同的空白。
你能解决这个问题吗?如果你不明白,我会解释清楚。
在本地,它工作得很好,但当我在网上更新时,它就不工作了。
发布于 2009-12-15 17:43:52
Hai sridhar,我找到了你的问题的答案
ClientScript.RegisterClientScriptBlock(GetType(), "sas", "<script> alert('Inserted successfully');</script>", true);将false更改为true
或者试试这个
ScriptManager.RegisterClientScriptBlock(ursavebuttonID, typeof(LinkButton or button), "sas", "<script> alert('Inserted successfully');</script>", true);发布于 2009-12-15 15:43:14
从MSDN2.0开始,System.Web.UI.Page.RegisterClientScriptBlock方法就已经被弃用了一段时间(以及其他的Page.Register*方法)。
改为使用.NET 2.0 方法。-( ClientScript属性表示ClientScriptManager的实例
猜测问题
如果您说您的JavaScript警告框发生在页面内容可见呈现之前,因此在警告框被用户关闭时页面仍然是白色(或仍然未呈现),那么请尝试使用Page.ClientScript.RegisterStartupScript(..) method,因为它会在页面完成加载时运行给定的客户端代码-而且它的参数与您已经使用的参数类似。
还要检查页面中的一般JavaScript错误-这通常通过浏览器状态栏中的错误图标看到。有时,JavaScript错误会阻塞或干扰页面上不相关的元素。
发布于 2011-05-19 13:41:22
看看下面的内容是否对你有帮助:
我之前使用的是以下代码:
ClientScript.RegisterClientScriptBlock(Page.GetType(), "AlertMsg", "<script language='javascript'>alert('The Web Policy need to be accepted to submit the new assessor information.');</script>");在此页面中实现AJAX后,它停止工作。在读完你的博客后,我把上面的内容改成:
ScriptManager.RegisterClientScriptBlock(imgBtnSubmit, this.GetType(), "AlertMsg", "<script language='javascript'>alert('The Web Policy need to be accepted to submit the new assessor information.');</script>", false);这一切都运行得很好。
(我正在使用的是.NET 2.0框架)
https://stackoverflow.com/questions/1905716
复制相似问题