Asp.net prompts information in iframe and executes the jump question

Source: Internet
Author: User

Copy codeThe Code is as follows:
/// <Summary>
/// In iframe, pop up the information and jump
/// </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 );
}

Call the cs file on the page
Copy codeThe Code is as follows:
Protected void btnSave_Click (object sender, EventArgs e)
{
If (bll. RoleAdd (model, tempMs ))
{
CmvspCommon. MessageBox. ResponseShowMsg ("saved successfully! "," Add. aspx ");
}
Else {
CmvspCommon. MessageBox. Show (this, "failed to save! ");
}
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.