显示ASP.NET C#重定向到另一个页面之前ClientScript警报? [英] showing ClientScript Alerts before Redirecting to another page in ASP.NET c#?
问题描述
我要在这里解决的一个问题...
I gotta address a problem here...
我正在开发一个系统,我不断地显示信息给用户,例如...
我添加一个新的客户,我输入的所有数据和preSS保存,打开C#我做的是做储蓄的所有过程,那么我用...
I'm developing a system where I am constantly showing Messages to the user, For instance... I'm adding a new client, I input all the data and press Save, ON C# what I do is do all the process of saving, then I use...
ClientScript.RegisterStartupScript(this.GetType(), "Mensaje", "alert('Client Saved Successfully');", true);
这就是它......最终,显示该消息,因为我住在同一个站点(因为如果我要添加其他客户端,我必须留在中小企业网站,而不是送我回我的主屏幕)或者至少我不会告诉系统做一个重定向...
And that's it... Eventually the message is displayed since I'm staying in the same site (because if I want to add another client, I must stay in the sme site, not send me back to my MAIN SCREEN) or at least I'm not telling the system to do a redirection...
不过这里的另一个例子......
However here's another example...
如果我要编辑一个客户,我重定向到编辑画面,我输入我所有的更改并点击保存,在C#我做所有的过程来保存更改,然后我用一个clientscript作为一上面,然后......
If I'm going to edit a client, I'm redirected to the edit screen, I input all my changes and click SAVe, on C# I do all the process to save changes, then I use a clientscript as the one above, and then ...
this.Response.Redirect("~/Main.aspx");
不过,我注意到,如果我使用的Response.Redirect我不会在同一个页面了,警报将不被显示给用户....
However, I noticed that if I use a Response.Redirect I will not be in the same page anymore, the alert won't be displayed to the user....
这是我遇到一个恒定的问题,我想知道这可能是解决这一...
This is a constant issue that I'm running into, and I would like to know what could be the solution to that...
感谢你,我希望你能帮助我。
Thank you and I hope you can help me
推荐答案
这是我为我的项目:
public static void jsAlertAndRedirect(System.Web.UI.Page instance, string Message, string url)
{
instance.Response.Write(@"<script language='javascript'>alert('" + Message + "');document.location.href='" + url + "'; </script>");
}
我这样使用它从一个网页:
I use it like this from a page:
HTMLHelper.jsAlertAndRedirect(this, "This is an alert.", ResolveUrl("~/Default.aspx"));
祝你好运。
这篇关于显示ASP.NET C#重定向到另一个页面之前ClientScript警报?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!