1、相关介绍:
在使用ASP.NET开发程序时,常常会使用到主页面与子页面数据的交互问题,例如:从子页面获取数据返回显示到主页面中,下面就来介绍下如何使用代码来完成此功能:
主页面:(在Load事件中增加窗体模式调用子页面)
以下是引用片段: protected void Page_Load(object sender, EventArgs e) { Button1.Attributes.Add("onclick", "var st = window.showModalDialog('Yp.aspx','参数','dialogHeight: 220px;status: no;');if(st!= null){ document.all('TextBox1').value+=st };return st;"); //点击按钮后打开Yp.aspx页面,将子页面返回值赋予TextBox1控件 }
|
子页面:
以下是引用片段: protected void Button1_Click(object sender, EventArgs e) { Page.RegisterStartupScript(代码); 代码:"OnClick", "" } //点击子页面提交按钮后将子页面中的Textbox1.Text值传递给主页面
|
注:一定要在弹出的子页面中的
中增加以下代码: 否则会弹出多余窗体。<责任编辑:计算机毕业设计网(http://www.xiaoniu168.com)>