如何在重定向之前显示消息。 [英] how to display a message before redirect.

查看:93
本文介绍了如何在重定向之前显示消息。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在重定向之前显示消息。

response.redirect(default.aspx)无效...

解决方案

< blockquote>尝试

 Response.Write(< script language ='javascript'> window.alert('Your Message'); window.location ='yourpage.aspx ';< / script>); 



它将显示弹出窗口消息,然后重定向到另一个网页。


< blockquote>你也可以通过创建javascript函数并在你的cs代码中调用它来做到这一点:



JavaScript函数:



函数ShowMessage()
{
alert(' 您的消息');
window.location.href = ' default.aspx';
}





CSharp代码:



 ScriptManager.RegisterStartupScript(this,this.GetType(),key,ShowMessage(),true); 





希望它有帮助:)


当你需要重定向你的页面时你替换你的 Response.redirect 是以下代码: -

 RegisterStartupScript(save,& lt; script type = \text / javascript \& gt; alert( '保存成功'); window.location.href =你的网址;& lt; / script& gt;); 


上面代码中的
是执行的显示消息并转到另一页。

我希望解决您的问题。


how to display a message before redirect.
response.redirect("default.aspx") is not working...

解决方案

Try

Response.Write("<script language='javascript'>window.alert('Your Message');window.location='yourpage.aspx';</script>");


It will display pop up window message, then after redirect to another web page.


you can also do it by creating the javascript function and calling it in your cs code like this:

JavaScript function:

function ShowMessage()
{
      alert('your message');
      window.location.href='default.aspx';
}



CSharp code:

ScriptManager.RegisterStartupScript(this, this.GetType(), "key", "ShowMessage()", true);



hope it helps :)


when you need to redirect your page you replace your Response.redirect is following code:-

RegisterStartupScript("save", "&lt;script type=\"text/javascript\"&gt; alert('Save successfully');  window.location.href = "your url"; &lt;/script&gt;");


in above code is execute and display message and go to another page.
I hope solve your problem.


这篇关于如何在重定向之前显示消息。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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