asp.net pops up a message in iframe and performs a jump problem discussion

  • 2020-06-03 06:12:56
  • OfStack

 
/// <summary> 
/// iframe  , the message pops up and jumps  
/// </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); 
} 

The page calls the cs file
 
protected void btnSave_Click(object sender, EventArgs e) 
{ 
if (bll.RoleAdd(model, tempMs)) 
{ 
CmvspCommon.MessageBox.ResponseShowMsg( " Save successfully! ", "add.aspx"); 
} 
else { 
CmvspCommon.MessageBox.Show(this, " Save failed! "); 
} 
} 

Related articles: