Response.Write("hello" +Request.Form["TextBox1"] +"<br>");
这样为什么取不到TextBox1的内容?

解决方案 »

  1.   

    你这样看看:Response.Write("hello" +TextBox1.Text.tostring +"<br>");
      

  2.   

    我是取上一个TextBox1.Text中的数据
      

  3.   

    我是取上一个页面的TextBox1.Text中的数据
      

  4.   

    当然不行不可以用 Request 接收服务器控件的数据要是在两个页面传递的话需要先把 TextBox1 的值作为上一个页面的一个属性值再用 Server.Transfer 跳转页面在下一个页面实例化上一个页面然后去那个属性你在 MSDN 帮助里搜 Transfer,有例子
      

  5.   

    我是取上一个TextBox1.Text中的数据
    ----------------------------------
    哪个上一个?
    你这种取法,必须在页面提交之后,才能得到值.而且NET中虽然这种做法也可,但不支持这样的取值方式.应使用 TextBox1.Text来取值.
      

  6.   

    原来是要这样取,可以的.但NET不再支持提交到其他页面了,要用Server.Transfer方式来传递要传递值的页面asm_content_view.aspx
    /// <summary>
    /// 搜索值
    /// </summary>
    public string strText
    {
      get
      {
        return(this.txtsearch.Text);
      }
    }/// <summary>
    /// 搜索类型
    /// </summary>
    public string strType
    {
      get
      {
        return(this.listsearch.SelectedValue);
      }
    }/// <summary>
    /// 搜索
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void butsearch_Click(object sender, System.EventArgs e)
    {
      this.Server.Transfer("asm_content_list.aspx");
    }
    要接收的页面
    //查看有无从asm_content_view页面转来的搜索对象
    string strname = Context.Handler.ToString().ToLower();
    if( strname == "asp.asm_content_view_aspx")
    {
      mydata.content.page.asm_content_view myform = new asm_content_view();        
      myform = (mydata.content.page.asm_content_view)Context.Handler;
      this.txtsearch.Text = myform.strText;
      this.listsearch.SelectedValue = myform.strType;
    }