欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

asp.net在iframe中弹出信息并执行跳转问题探讨

程序员文章站 2024-03-02 08:44:04
复制代码 代码如下: /// /// iframe 中,弹出信息并跳转 /// ///
复制代码 代码如下:

/// <summary>
/// iframe 中,弹出信息并跳转
/// </summary>
/// <param name="msg"></param>
/// <param name="targetpagename"></param>
public static void responseshowmsg(string msg, string targetpagename)
{
string str = "<script> alert('{0}'); window.parent.frames[\"sysmain\"].location.href = '{1}'; </script>";
string urls = httpcontext.current.request.url.originalstring;
if (urls.lastindexof('?') > 0)
{
urls = urls.substring(0, urls.lastindexof('?')).replace(httpcontext.current.request.url.segments[httpcontext.current.request.url.segments.length - 1], targetpagename);
}
else
{
urls = urls.replace(httpcontext.current.request.url.segments[httpcontext.current.request.url.segments.length - 1], targetpagename);
}
str = string.format(str, msg, urls);
httpcontext.current.response.write(str);
}

页面调用 cs文件
复制代码 代码如下:

protected void btnsave_click(object sender, eventargs e)
{
if (bll.roleadd(model, tempms))
{
cmvspcommon.messagebox.responseshowmsg( "保存成功!", "add.aspx");
}
else {
cmvspcommon.messagebox.show(this, "保存失败!");
}
}