小迪的Blog
学习ing...(注明:该Blog中的任何信息都非原创,只是作为个人的阅读笔记)

在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();");
 }
}

posted on 2005-04-03 17:05  小迪  阅读(559)  评论(0编辑  收藏  举报