响应.重定向消除了脚本管理器操作
Response.Redirect eliminates the script manager action
我有以下问题。我有一个输入客户数据的表单。之后,表单将向用户提供消息,表明操作已成功完成:
ScriptManager.RegisterStartupScript(this, GetType(), "Success",
"alert('Successfully input');", true);
然后,它将使用以下命令重新加载页面:
Response.Redirect("customer_data.aspx");
我的问题是,第一个命令不工作,如果我把第二个。如果去掉第二个,它就能正常工作。我甚至试过使用:
try
{
ScriptManager.RegisterStartupScript(this, GetType(), "Success", "alert('Successfully input');", true);
}
finally
{
Response.Redirect("customer_data.aspx");
}
,但是第一个命令仍然不起作用。请帮助。
这是因为ASP。. NET使您无法理解客户端
上发生的事情。Response.Redirect("customer_data.aspx");
发送http报头
Location=customer_data.aspx
和
ScriptManager.RegisterStartupScript(this, GetType(), "Success",
"alert('Successfully input');", true);
呈现<script type="text/javascript">
alert('Successfully input');
</script>
在页尾。当然,如果在http头中设置了位置,浏览器将执行重定向,并且不会执行页面上的脚本。你可以在javascript中显示警告后执行重定向:
ScriptManager.RegisterStartupScript(this, GetType(), "Success",
"alert('Successfully input');location.href='customer_data.aspx'", true);
我认为同一页面的Response.Redirect
被检测为引起循环。您可以尝试使用script重新加载:
ScriptManager.RegisterStartupScript(this, GetType(), "Success",
"alert('Successfully input');window.location.reload(true);", true);
你可以这样写:
string answer = "Success";
ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect",
"alert('" + answer + "'); window.location.href='index.aspx';", true);
相关文章:
- 如何在elfinder插件(一个文件管理器插件)上获得上传前事件
- 如何访问声音管理器2创建的声音对象
- JS编译器/包管理器,用于版本控制
- 加载两个脚本块(使用lab.js作为加载管理器)
- Ajax脚本管理器阻止了jquery
- ASP.Net 将脚本添加到脚本管理器时,更新进度中断
- 为什么谷歌跟踪代码管理器使用IFrame而不是脚本DOM元素
- 谷歌标签管理器添加&instrad of just&转换为脚本src
- ng if和谷歌标签管理器脚本
- ASP.NET脚本管理器在执行代码后运行
- 带有时间选择器的脚本管理器
- 从UserControl的资源文件运行一个jQuery脚本到client的脚本管理器
- 在脚本中使用PHP发送数据到Google标签管理器
- 在vb.net中使用脚本管理器动态追加时间
- 谷歌标签管理器脚本在头won'不允许在href中进行更改
- 如何修改jquery照片管理器脚本,以使用更多的框
- 您可以配置Adobe动态标记管理器(DTM),以便在设置数据元素之前加载脚本吗?
- 谷歌应用程序脚本事件管理器
- 在Microsoft AJAX Partial Postback上向脚本管理器添加脚本引用(JavaScript)
- 响应.重定向消除了脚本管理器操作