7

在我的网络应用程序中,当我上传视频并单击保存按钮时,如果上传了视频,我编写代码以显示消息视频已上传。我的代码如下:

ClientScript.RegisterClientScriptBlock(GetType(), "sas", "<script> alert('Inserted successfully');</script>", false);

当警报框出现时带有白色背景。我在该警报框中单击了“确定”按钮,但该页面没有返回到显示相同空白区域的上一页。

你能解决问题吗。?如果你不明白我会解释清楚。

在本地它工作正常,但是当我在线更新时它不起作用。

4

3 回答 3

15

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-15T09:43:52.413 回答
1

自 MSDN 所示的 .NET 2.0 以来,方法System.Web.UI.Page.RegisterClientScriptBlock已被弃用一段时间(连同其他 Page.Register* 方法)。

而是使用 .NET 2.0 Page.ClientScript.Register*方法。 -(ClientScript 属性表示ClientScriptManager类的一个实例)

猜测问题

如果您说您的 JavaScript 警报框出现在页面内容可见呈现之前,因此当用户关闭警报框时页面保持白色(或仍未呈现),请尝试使用Page.ClientScript.RegisterStartupScript(.. ) 方法,因为它在页面完成加载时运行给定的客户端代码- 它的参数类似于您已经使用的参数。

还要检查页面中的一般 JavaScript 错误- 这通常通过浏览器状态栏中的错误图标看到。有时,JavaScript 错误会阻碍或干扰页面上不相关的元素。

于 2009-12-15T07:43:14.387 回答
1

看看以下内容是否对您有帮助:

我之前使用的是以下内容:

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 框架,我正在使用)

于 2011-05-19T05:41:22.383 回答