我现在这个页面叫做WebForm1,现在想调用WebForm2页面中的Textbox1,有什么办法呢?

解决方案 »

  1.   

    源页面代码:
    把以下的代码添加到页面中
    public string Name
    {
    get
    {
    return TextBox1.Text;
    }
    }public string EMail
    {
    get
    {
    return TextBox2.Text;
    }
    }
    然后调用Server.Transfer方法
    private void Button1_Click
    (object sender, System.EventArgs e)
    {
    Server.Transfer("anotherwebform.aspx");
    }目标页面代码:
    private void Page_Load
    (object sender, System.EventArgs e)
    {
    WebForm1 wf1;//create instance of source web form
    wf1=(WebForm1)Context.Handler;//get reference to current handler instance
    Label1.Text=wf1.Name;
    Label2.Text=wf1.EMail;
    }
      

  2.   

    发送页:
        1.定义静态变量:  public static string str="";
        2. str=this.TextBox1.Text;
           Server.Transfer("webform2.aspx");
     接收页:
        1.引入第一页的命名空间:using WebApplication1;
        2  this.TextBox1.Text=WebForm1.str;
      

  3.   

    同意楼上.引用其他页面的命名空间.就可以调用了.不过要把那么的控件的私有改为public
    这样才能被调用