在WebForm中实现模拟对话框效果

在WebForm中实现模拟对话框效果

在WebForm1.aspx中:
private void Page_Load(object sender, System.EventArgs e)
{
 // 在此处放置用户代码以初始化页面
 if(!IsPostBack)
  btnOpen.Attributes.Add("onclick", @"var strReturn; strReturn=window.showModalDialog('DialogForm.aspx',null,'status:no;dialogWidth:250px;dialogHeight:125px;dialogHide:true;help:no;scroll:no');if (strReturn != null) document.getElementById('txtValue').value=strReturn;");
}

在WebForm2.aspx中:
private void Page_Load(object sender, System.EventArgs e)
{
 if(!IsPostBack )
 {
  btnOK.Attributes.Add("onclick", @"window.returnValue = document.getElementById('txtValue').value; window.close();");
  btnCancel.Attributes.Add("onclick", @"window.close();");
 }
}

原文地址:https://www.cnblogs.com/xiaodi/p/131328.html