参数传递,有一定的难度!!!! 好像没有什么难度嘛。就用session,很好的方法。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 关键是要重新绑定啊,当然可以用session拉,但是我问题的是要加一个button来获取参数啊,这样很麻烦啊,我不想加一个button啊你有什么好办法啊! 参数传递的方法一般常见的有三种情况来着!比较常用的是用Session!eg.Session["temp"]=Text2.Text.Trim(); 我就是用session来传递的,关键是回传参数后,要求原来页面的内容不能改变啊,我在问题中用的两种返回方式中都是用session来传递的,但是主要是回传后页面1应该怎样绑定啊,我说了,难道真的要加一个button来实现对textbox1进行重新绑定?————————————————————————————————希望大虾们能够明白我的意图!!!同时感谢以上各位大虾的指点!!! 可不可以采用弹出对话框的方式嘛?那样就可以页面1:有两个文本框textbox1,textbox2,一个button其中文本框textbox2已经输入数据,点击button进入页面2获取参数,并传递给页面1中的textbox1。要求返回时页面1中的textbox2中的内容不能变。方法一:若采用Response.Redirect("WebForm1.aspx")则textbox2中的内容不能保存方法二:若采用Response.Write( "<script> history.go(-2); </script>" )则必须添加一个button来获取传递过来的参数!请问大家有没有更好的办法。所以说的这么复杂,主要是因为textbox2中的内容是从数据库中绑定的,需要从第三个页面传递来的一个参数,所以采用方法一时无法再对textbox2绑定了!!! 我用window.open的方法打开后却不能关闭,不知道为什么?String sUrl = "WebForm4.aspx?Id=" + TextBox1.Text; String sFeatures = "'height=320;width=160;left=100;top=50;location=no;menubar=no;resizable=yes;scrollbars=no;status=no;titlebar=yes;toolbar=no'"; String sScript =""; sScript += "<script language=javascript>"; sScript += "window.open('" + sUrl + "',''," + sFeatures + ");"; sScript += "</script>"; Response.Write(sScript);————————————————————————————————String sId = TextBox2.Text; String sScript = ""; sScript += "<script language=javascript>"; sScript += " window.opener.Form1.TextBox2.value = '" + sId + "';"; sScript += " window.close();"; sScript += "</script>"; Response.Write(sScript to imfine()但是页面1有好几个页面都要定向到他上面,所以不能把所有的代码都放到page_load里面啊!private void Page_Load(object sender, System.EventArgs e) { if(!IsPostBack) { //string member = Request.QueryString.Get("Member"); string draftID=Request.QueryString.Get("DraftID"); string sendMailID=Request.QueryString.Get("SendMailID"); string str1=Request.QueryString.Get("str1"); if(sendMailID!=null) { this.BindData2(Convert.ToInt32(sendMailID)); } if(draftID!=null) { this.BindData1(Convert.ToInt32(draftID)); } if(Session["to"]!=null || Session["cc"]!=null || Session["bcc"]!=null) { if(sendMailID!=null) { this.BindData2(Convert.ToInt32(sendMailID)); } if(draftID!=null) { this.BindData1(Convert.ToInt32(draftID)); } if(Session["to"]!=null) { TextBox1.Text=Session["to"].ToString(); Session.Remove("to"); } if(Session["cc"]!=null) { TextBox2.Text=Session["cc"].ToString(); Session.Remove("cc"); } if(Session["bcc"]!=null) { TextBox3.Text=Session["bcc"].ToString(); Session.Remove("bcc"); } } } // 在此处放置用户代码以初始化页面 } 上面是页面的代码,各位大虾看如何实现啊其中(Session["to"], Session["cc"],Session["bcc"])是从页面2传过来的,SendmailID是从页面3传过来的,draftID是从页面4穿过来的,程序先从页面3或页面4定向到页面1,并绑定数据到TextBox2,然后到页面2选择所要的数据,然后返回页面1,并绑定数据到TextBox1中!!! to arbinger(阿彬哥)那要怎么保存页面3/4中的变量,难道又要用session? 在A页面中用JAVASCRIPT弹出B页面Response.Write("<script Language=JavaScript>");string url="B.aspx Response.Write("ChildWindow = window.open('"+url+"', '111', 'width=220,height=200,top=180,left=280,toolbar=no,status=yes,location=no,menubar=no,directories=no,scrollbars=no,resizable=no')");Response.Write("</script>");在B页面中用JAVASCRIPT回传参数Response.Write("<script Language=JavaScript>");Response.Write("window.opener.document.forms['newmessage'].elements['Return'].value ='"你要回传的STRING"';");Response.Write("window.close();");Response.Write("</script>");Return是A页面中的TEXTBOX 的ID,newmessage是A页面 to imfine()请问大虾你是不是用的windows窗体做的啊,我的弹出页面2后,就不能关闭了不知道为什么? 请教FTP的问题,请大家帮帮忙~ 换了个服务器后运行就报这样的错误,以前iis是5.1版本的现在是6.0版本的,会不会跟iis的版本有关啊·这怎么改啊 在a.aspx?id=3中JS调用showModalDialog返回后,querystring id变成空 用Command进行批量更新时报错大侠们帮帮忙 页面聊天室思路 SQL Sever与Access互转 菜鸟请教,几个基础问题....... 请教:微软LCS与腾讯RTX比有什么优势和劣势? 新手的若干问题 帮看一下这个域名值多少钱? 出错判断!在线等待! 用asp.net(vb)如何连接Access和SQL SERVER数据库的?
eg.Session["temp"]=Text2.Text.Trim();
————————————————————————————————
希望大虾们能够明白我的意图!!!
同时感谢以上各位大虾的指点!!!
页面1:
有两个文本框textbox1,textbox2,一个button
其中文本框textbox2已经输入数据,
点击button进入页面2获取参数,并传递给页面1中的textbox1。要求返回时页面1中的textbox2中的内容不能变。
方法一:若采用Response.Redirect("WebForm1.aspx")则textbox2中的内容不能保存
方法二:若采用Response.Write( "<script> history.go(-2); </script>" )则必须添加一个button来获取传递过来的参数!请问大家有没有更好的办法。
所以说的这么复杂,主要是因为textbox2中的内容是从数据库中绑定的,需要从第三个页面传递来的一个参数,所以采用方法一时无法再对textbox2绑定了!!!
String sUrl = "WebForm4.aspx?Id=" + TextBox1.Text;
String sFeatures = "'height=320;width=160;left=100;top=50;location=no;menubar=no;resizable=yes;scrollbars=no;status=no;titlebar=yes;toolbar=no'";
String sScript ="";
sScript += "<script language=javascript>";
sScript += "window.open('" + sUrl + "',''," + sFeatures + ");";
sScript += "</script>";
Response.Write(sScript);————————————————————————————————String sId = TextBox2.Text;
String sScript = "";
sScript += "<script language=javascript>";
sScript += " window.opener.Form1.TextBox2.value = '" + sId + "';";
sScript += " window.close();";
sScript += "</script>";
Response.Write(sScript
但是页面1有好几个页面都要定向到他上面,所以不能把所有的代码都放到page_load里面啊!
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
//string member = Request.QueryString.Get("Member");
string draftID=Request.QueryString.Get("DraftID");
string sendMailID=Request.QueryString.Get("SendMailID");
string str1=Request.QueryString.Get("str1");
if(sendMailID!=null)
{
this.BindData2(Convert.ToInt32(sendMailID));
}
if(draftID!=null)
{
this.BindData1(Convert.ToInt32(draftID));
}
if(Session["to"]!=null || Session["cc"]!=null || Session["bcc"]!=null)
{
if(sendMailID!=null)
{
this.BindData2(Convert.ToInt32(sendMailID));
}
if(draftID!=null)
{
this.BindData1(Convert.ToInt32(draftID));
}
if(Session["to"]!=null)
{
TextBox1.Text=Session["to"].ToString();
Session.Remove("to");
}
if(Session["cc"]!=null)
{
TextBox2.Text=Session["cc"].ToString();
Session.Remove("cc");
}
if(Session["bcc"]!=null)
{
TextBox3.Text=Session["bcc"].ToString();
Session.Remove("bcc");
}
}
} // 在此处放置用户代码以初始化页面
}
那要怎么保存页面3/4中的变量,难道又要用session?
Response.Write("<script Language=JavaScript>");
string url="B.aspx
Response.Write("ChildWindow = window.open('"+url+"', '111', 'width=220,height=200,top=180,left=280,toolbar=no,status=yes,location=no,menubar=no,directories=no,scrollbars=no,resizable=no')");
Response.Write("</script>");
在B页面中用JAVASCRIPT回传参数
Response.Write("<script Language=JavaScript>");
Response.Write("window.opener.document.forms['newmessage'].elements['Return'].value ='"你要回传的STRING"';");
Response.Write("window.close();");
Response.Write("</script>");Return是A页面中的TEXTBOX 的ID,newmessage是A页面
请问大虾你是不是用的windows窗体做的啊,我的弹出页面2后,就不能关闭了不知道为什么?