asp.net在iframe中弹出信息并执行跳转问题探讨
asp.net在iframe中弹出信息并执行跳转问题探讨
发布时间:2016-12-29 来源:查字典编辑
摘要:复制代码代码如下://////iframe中,弹出信息并跳转/////////publicstaticvoidResponseShowMsg...

复制代码 代码如下:

/// <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, "保存失败!");

}

}

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新asp.net教程学习
热门asp.net教程学习
编程开发子分类