在模式窗口中提交不弹出新窗口(转载)
原文:http://blog.csdn.net/xue1225go0104/article/details/2347267
1.在模式窗口中提交不弹出新窗口:
在<head></head>中加<base target="_self" />
并在要点击的按钮上加PostBackUrl="#"
或者
新建一个ShowModal页面,在aspx页面中加
<iframe id="MainWindow" width="100%" scrolling="auto" height="100%" runat="server">
</iframe>
在aspx.cs页面中加
if (!Page.IsPostBack)
{
string strLinkFlag = Request.QueryString["LinkFlag"].ToString();
switch (strLinkFlag)
{
case "NoticeInfo":
strTitle = "公告信息";
strUrlLink = "NoticeInfo.aspx?flag=" + Request.QueryString["Flag"].ToString();
break;
default:
break;
}
if (strUrlLink != String.Empty)
{
//添加随机数,防止IE缓存
string strRandom = BaseFunction.GetFormatDate();
strUrlLink += "&randomnum=" + strRandom;
MainWindow.Attributes.Add("src", strUrlLink);
}
}
在弹出窗体的aspx页面中加
<script type="text/jscript" language="javascript">
function OpenEditWin(frmWin,width,height)
{
var me;
// 把父页面窗口对象当作参数传递到对话框中,以便对话框操纵父页自动刷新。
me = window;
// 显示对话框。
window.showModalDialog(frmWin,me,'dialogWidth='+width +'px;dialogHeight='+height+'px;help:no;status:no')
return false;
}
</script>
aspx.cs页面中:
//用模态对话框弹出公告信息页面
showForm = "ShowModelPage.aspx?linkFlag=NoticeInfo&Flag=" + noticeID;
lnkTitle.Attributes.Add("onclick", "javascript:return OpenEditWin('" + showForm + "',600,500)");
浙公网安备 33010602011771号