aso.net中的消息框出现问题 [英] problem with message box in aso.net

查看:78
本文介绍了aso.net中的消息框出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨...
我将此代码用于meesag框....
MsgBox1.alert("HI");
Response.Redirect("default2.aspx");

如果我只写MsgBox1.alert("HI");
它显示消息....
但是当我写
MsgBox1.alert("HI");
Response.Redirect("default2.aspx");
它会转到没有显示消息的下一页....
请解决我的问题........

hi...
i using this code for meesag box....
MsgBox1.alert("HI");
Response.Redirect("default2.aspx");

if i write the only MsgBox1.alert("HI");
its show meesage....
but when i write
MsgBox1.alert("HI");
Response.Redirect("default2.aspx");
it go to next page without show message....
plese solve my problem........

推荐答案

什么是MsgBox1?某种自定义类将javascript注入到Response流中?

在Asp.Net(或任何Web开发)中,消息框用于客户端-您应该使用 javascript警报来显示它们. [ ^ ]函数

您应该避免在服务器端代码中使用它们,而这并不是放置它们的地方-您无法像这样控制流程.例如,将消息框发送回客户端,等待他们单击确定",然后重定向.
What is MsgBox1? Some sort of custom class that injects javascript into the Response stream?

In Asp.Net (or any web development), message boxes are for the client side - you should be showing them using the javascript alert[^] function

You should be avoiding using them in your server side code, that''s not the place for them - you can''t control flow like that. E.g send a message box back to the client, wait for them to click ok, then redirect.


用aspx中的一些javascript替换它,如下所示:
Replace it with some javascript in your aspx, like this:
alert(''HI''); 
window.location.href = ''default2.aspx'';


或在您的代码后面,如下所示:


Or in your code behind, like this:

Page.RegisterClientScriptBlock("","<script>alert(''HI''); window.location.href = ''default2.aspx'';</script>");



祝你好运!



Good luck!


这篇关于aso.net中的消息框出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆