父窗体中弹出新窗体,如何将子窗口的字符串传给父窗体。 opener.document.getelementbyid,用这个方法可以吗,怎么用了,各位是否能给我实例。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Form1类: textBox1:显示来自Form2的值 button1:调出Form2窗口 public string strval//传值与赋值属性 { get{return this.textBox1.Text;} set{this.textBox1.Text = value;} } button1_Click事件: Form2 f2 = new Form2(); f2.Owner = this; f2.ShowDialog();Form2类: textBox1:设置Form1中TextBox的值 button1:赋值按钮 button1_Click事件: Form1 f1 = (Form1)this.Owner; f1.strval = this.textBox1.Text; txtID在父窗口中是个textboxResponse.Write(@"<script language='javascript'>" + "opener.document.all.txtID.value ='abc';" + "</script>"); 传值 ParentPage.aspx: window.showModalDialog("DialogPage.aspx?para1=aaa?2=bbb"); DialogPage.aspx: string str1=Request.QueryString["para1"].toString(); string str2=Request.QueryString["para2"].toString(); 返回值 DialogPage.aspx: window.returnvalue="aaa"; ParentPage.aspx: var str=window.showModalDialog("DialogPage.aspx"); 谢谢chinasdp() 这个实例您已经实现了吗?f2.Owner = this;f2.ShowDialog();(Form1)this.Owner;Owner和ShowDialog没有Web程序里没有提供这两个属性和方法。您说的是win程序吗。对不起,我没说清楚,我做的是web程序。谢谢你。 ralpha08(被水淹死的鱼) txtID在父窗口中是个textboxResponse.Write(@"<script language='javascript'>" + "opener.document.all.txtID.value ='abc';" + "</script>");谢谢您,不很明白你的回复是什么意思,这句话写在哪儿,父窗口下,还是子窗口下。“txtID在父窗口中是个textbox”我已经按你的去做了。把这段程序写在了子窗口下,结果点按纽后,又弹出一个子窗口。另外:您这句话是依据什么给父窗口传值的,为什么这句话就确认就能传到父窗口呢。"opener.document.all.txtID.value ='abc';"仅仅依据这一行代码?谢谢 jc15271149(嘿咻)返回值 DialogPage.aspx: window.returnvalue="aaa"; ParentPage.aspx: var str=window.showModalDialog("DialogPage.aspx");您可以具体谈谈怎么接受子窗口的值吗。window.returnvalue="aaa"; 这句话写在哪儿。找不到window这个东西。用什么传按纽吗?按纽事件怎么写。 这段代码写在子窗口中 譬如可以写在一个Button的OnClick事件中这样点击这个Button的时候 父窗口的txtID的text属性就会是"abc"Response.Write(@"<script language='javascript'>" + "opener.document.all.txtID.value ='abc';" + "</script>") ralpha08(被水淹死的鱼) 大哥,我实验了,不行。点这个按钮后又弹出一个新的子窗口。父窗口主要代码:protected System.Web.UI.WebControls.TextBox txtID;//此文本框接受由子窗口传入的值private void Button1_Click(object sender, System.EventArgs e){ string s="javascript: window.showModalDialog('WebForm2.aspx');"; this.Button1.Attributes["onclick"]=s;//为什么总是慢半拍呢??}子窗口主要代码:protected System.Web.UI.WebControls.TextBox TextBox1;//此文本框写要传入父窗口的字符private void Button1_Click(object sender, System.EventArgs e){ Response.Write(@"<script language='javascript'>" + "opener.document.all.txtID.value ='abc';" + "</script>")}你看,这是两个页面的主要代码,可是还是不行。 父窗口主要代码改为:protected System.Web.UI.WebControls.TextBox txtID;//此文本框接受由子窗口传入的值private void Button1_Click(object sender, System.EventArgs e){ Response.Write(@"<script language='javascript'>" + "window.open('WebForm2.aspx','win','width=200,height=200');" + "</script>")} ralpha08(被水淹死的鱼),谢谢你呀!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!真的搞定了。 也谢谢各位的关注。特别鸣谢ralpha08(被水淹死的鱼)。 请问一下,谁知道中国移动与中国联通是否向外提供 手机号码归属地查询的接口,供程序调用,如何联系他们?急急急 如何解决这个问题:textarea 输入多行,显示的时候还是显示多行 如何得到html里的图片地址? 怎样学好.net 有Crystal Reports高手? dropdownlist默认值 刚学 谁能来帮帮我 用户控件的属性可以得到aspx页面的值,但是通过用户控件的page_load的时候,这个值就丢了。 大家帮忙看看有关ASP.NET的图片转换 请问关于日历控件的问题,请大家帮忙 TreeView不能显示 小问题
textBox1:显示来自Form2的值
button1:调出Form2窗口
public string strval//传值与赋值属性
{
get{return this.textBox1.Text;}
set{this.textBox1.Text = value;}
}
button1_Click事件:
Form2 f2 = new Form2();
f2.Owner = this;
f2.ShowDialog();Form2类:
textBox1:设置Form1中TextBox的值
button1:赋值按钮
button1_Click事件:
Form1 f1 = (Form1)this.Owner;
f1.strval = this.textBox1.Text;
+ "opener.document.all.txtID.value ='abc';"
+ "</script>");
ParentPage.aspx:
window.showModalDialog("DialogPage.aspx?para1=aaa?2=bbb"); DialogPage.aspx:
string str1=Request.QueryString["para1"].toString();
string str2=Request.QueryString["para2"].toString(); 返回值
DialogPage.aspx:
window.returnvalue="aaa"; ParentPage.aspx:
var str=window.showModalDialog("DialogPage.aspx");
f2.ShowDialog();
(Form1)this.Owner;Owner和ShowDialog没有Web程序里没有提供这两个属性和方法。您说的是win程序吗。对不起,我没说清楚,我做的是web程序。谢谢你。
txtID在父窗口中是个textbox
Response.Write(@"<script language='javascript'>"
+ "opener.document.all.txtID.value ='abc';"
+ "</script>");谢谢您,不很明白你的回复是什么意思,这句话写在哪儿,父窗口下,还是子窗口下。“txtID在父窗口中是个textbox”我已经按你的去做了。把这段程序写在了子窗口下,结果点按纽后,又弹出一个子窗口。另外:您这句话是依据什么给父窗口传值的,为什么这句话就确认就能传到父窗口呢。"opener.document.all.txtID.value ='abc';"仅仅依据这一行代码?谢谢
DialogPage.aspx:
window.returnvalue="aaa"; ParentPage.aspx:
var str=window.showModalDialog("DialogPage.aspx");您可以具体谈谈怎么接受子窗口的值吗。
window.returnvalue="aaa"; 这句话写在哪儿。找不到window这个东西。用什么传
按纽吗?按纽事件怎么写。
譬如可以写在一个Button的OnClick事件中这样点击这个Button的时候 父窗口的
txtID的text属性就会是"abc"Response.Write(@"<script language='javascript'>"
+ "opener.document.all.txtID.value ='abc';"
+ "</script>")
protected System.Web.UI.WebControls.TextBox txtID;//此文本框接受由子窗口传入的值
private void Button1_Click(object sender, System.EventArgs e)
{
string s="javascript: window.showModalDialog('WebForm2.aspx');";
this.Button1.Attributes["onclick"]=s;//为什么总是慢半拍呢??
}子窗口主要代码:
protected System.Web.UI.WebControls.TextBox TextBox1;//此文本框写要传入父窗口的字符
private void Button1_Click(object sender, System.EventArgs e)
{
Response.Write(@"<script language='javascript'>"
+ "opener.document.all.txtID.value ='abc';"
+ "</script>")
}你看,这是两个页面的主要代码,可是还是不行。
protected System.Web.UI.WebControls.TextBox txtID;//此文本框接受由子窗口传入的值
private void Button1_Click(object sender, System.EventArgs e)
{
Response.Write(@"<script language='javascript'>"
+ "window.open('WebForm2.aspx','win','width=200,height=200');"
+ "</script>")
}