.net中子窗体的值如何回传给父窗体的文本框
解决方案 »
- 脚本问题
- 服务器端出了问题,aspx页面不响应,大家帮我分析分析
- 在Oracle存储过程中如何应用事务....
- 请高手帮忙!如何在tabstrip子页面中调用父页面方法
- TextBox与CalendarExtender配合使用出现 Sys.ArgumentOutOfRangeException: 值必须为整数。
- Compiler Error Message: BC30002: Type 'ADOConnection' is not defined.
- 求高人指点:<ext:button enabled="false" id="btn" >行点击事件,用js设置butoon可用
- 水晶报表一个问题,求解!100分!
- 请问:哪里能找到比较多的asp.net代码
- 再问一下,在DataList中,使用修改编辑模板,在Update内容时,为何用Button来提交不能调用Sub,而用LinkButton就可以成功调用?
- 什么叫发布存储过程啊?
- 请问asp.net中如何控制页面历史状态,不让用户按后退或键盘上的退格键来返回上一页?
子体.显示方法子体.属性="想要的值"父体.文本框=子体.属性是这个意思吗
classC:子类
在父类中
classC child = new classC(this)
child.show();在子类中的构造函数中可以自定义
classP p;
public classC(classP parent)
{}然后你就可以随便用父窗体的东西了.设定父窗体的文本框还不简单
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<input id="Button1" type="button" value="高级查询" onclick="window.open('Test_B.aspx','newwindow','width=300px,height=100px,top=300px,left=300px')"/>
<asp:TextBox ID="txtProductName" runat="server" Text=""></asp:TextBox>
<asp:Button ID="btnSearch" runat="server" Text="查询" OnClick="btnSearch_Click" />
<asp:GridView ID="objGridView" runat="server">
</asp:GridView>
<asp:TextBox ID="txtParent" runat="server" Text = "aaa"></asp:TextBox>
<input id="Button2" type="button" value="父窗体传值给子窗体" onclick="window.open('Test_B.aspx','newwindow','width=300px,height=100px,top=300px,left=300px')"/>
</div>
</form>
</body>
</html><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<script language="javascript" type="text/javascript">
<!--function window_onload() {
document.getElementById("txtChildren").value = opener.document.getElementById("txtParent").value;
}
function setValue()
{
opener.document.getElementById('txtProductName').value = document.getElementById('txtCondition').value;
opener.document.getElementById('btnSearch').click();
self.close();
}
// -->
</script>
</head>
<body language="javascript" onload="return window_onload()">
<form id="form1" runat="server">
<div>
产品名称:<asp:TextBox ID="txtCondition" runat="server"></asp:TextBox>
<asp:Button ID="btnSearch" runat="server" Text="查询" OnClientClick="opener.document.getElementById('txtProductName').value = document.getElementById('txtCondition').value;opener.document.getElementById('btnSearch').click();self.close();" />
<input type="button" value="子窗体传回给交窗体值" onclick="setValue();" />
<asp:TextBox ID="txtChildren" runat="server"></asp:TextBox>
</div>
</form>
</body>
</html>
1: 所有权法
//Form1:
//需要有一个公共的刷新方法
public void Refresh_Method()
{
//...
}
//在调用Form2时,要把Form2的所有者设为Form1
Form2 f2 = new Form2() ;
f2.Owner = this;
f2.ShowDialog() ;
//Form2:
//在需要对其调用者(父)刷新时
Form1 f1 ;
f1 = (Form1)this.Owner;
f1.Refresh_Method() ;eg:Form1中的函数: public void DiaoYong(string str)
{
this.textBox1.Text =str;
}private void button2_Click(object sender, EventArgs e)
{ string str = this.textBox1.Text;
Form2 f2 = new Form2(str);//在构造函数中,向子窗体传值。
f2.Owner = this;
f2.ShowDialog();
}Form2中的函数: public Form2(string ss)
{
InitializeComponent();
this.textBox1.Text = ss; } private void button1_Click(object sender, EventArgs e)
{
string st = textBox1.Text; Form1 f1;
f1 = (Form1)this.Owner;
f1.DiaoYong(st); this.Close();
}
太多了
===============
ASP.NET
function vv()
{
kv=window.showModalDialog("test2.aspx",window,"center:yes;status:no;scroll:no;help:no;dialogWidth=320px;dialogHeight=150px");
/* 1
var newoption=document.createElement("Option")
newoption.text=kv;
document.getElementById("ee").options.add(newoption);
*/
/*2*/
var option=new Option(kv,kv);
document.getElementById("ee").options.add(option);
} function cc()
{
/*一种方案:子窗体直接给父窗体赋值,事件全部在子窗体中处理*/
window.dialogArguments.document.Form1.Text1.value=document.getElementById('s2').value;
/* 正确赋值*/
var newoption=window.dialogArguments.document.createElement("Option")
newoption.text=document.getElementById('s2').value;
window.dialogArguments.document.getElementById("ss").options.add(newoption);
/*第二种方案:子窗体将值传回父窗体,由父窗体处理*/
window.returnValue= document.getElementById('s2').value;
window.close();
}
function vv()
{
g_pop=new Popup({ contentType:1,isReloadOnClose:false,width:420, height:150 });
g_pop.setContent("title","添加新标题");
g_pop.setContent("contentUrl","test3.aspx");
g_pop.build();
g_pop.show();
}