可以用属性传递 在有文本框的页面定义一个属性 private strin _name; public string name { get { return _name; } set {_name = value;} } this name = this.TestBox.text在另一个页面 if(context.Handler.Tostring() =="第一个页面名字") { 类名.LioBJ = Context.Handler as 类名; this.TextBox1.Text = LioBJ.name; }
不行的,你的this 指的是同一個頁面,你可以設置第一個頁面的屬性為第一個頁面的textBox.text 這樣你在第二個頁面里產生第一個頁面時,然後直接調用他的屬性就好了 代碼如下 第一個頁面的名字為 webform1 他的屬性 public string name {get{return this.textBox.text.ToString();}} 第二個頁面里調用他的屬性 public webform1 SourcePage; string name =SourcePage.name.Trim();
第一個頁面的名字為 webform1 他的屬性 public string name {get{return this.textBox.text.ToString();}} 裡面的this可以不要的 可以寫成 public string name {get{return textBox.text.ToString();}}
在有文本框的页面定义一个属性
private strin _name;
public string name
{
get
{
return _name;
}
set
{_name = value;}
}
this name = this.TestBox.text在另一个页面
if(context.Handler.Tostring() =="第一个页面名字")
{
类名.LioBJ = Context.Handler as 类名;
this.TextBox1.Text = LioBJ.name;
}
,最后是自定义控件隐藏session式的传送
在form1里写:
private string _name;
public string name
{
get{return _name;}
set{_name = value;}
}
this.name = this.textBox.text;在另一个页面form2中就可以用下面的方法调用:(假设form2中有textBox2)
form2.textBox2.text = form1.name;
我没有办法执行这句 this.name = this.textBox.text;
是在第二个页用到第一个页text框的值,有没有方法可以直接取得
這樣你在第二個頁面里產生第一個頁面時,然後直接調用他的屬性就好了 代碼如下
第一個頁面的名字為 webform1 他的屬性
public string name {get{return this.textBox.text.ToString();}}
第二個頁面里調用他的屬性
public webform1 SourcePage;
string name =SourcePage.name.Trim();
public string name {get{return this.textBox.text.ToString();}}
裡面的this可以不要的 可以寫成
public string name {get{return textBox.text.ToString();}}
才能在别的页面访问或者
request["x"]也可以,
e页面的生存期很短,所以无法访问它的实例化成员的值,应该用设置为static类型
才能在别的页面访问或者
request["x"]也可以,這種方法好像只能實現倆個頁面直接跳轉的參數傳遞,我的那種方法,只要是同一個專案下面就可以