您的位置:首页 > 编程语言 > ASP

asp.net 在iframe 中页面跳转问题 js

2013-04-19 17:04 399 查看
/// <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, "保存失败!");
            }
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: