index.aspx
-----------------------<HTML>
<HEAD>
     <title>index</title>
</HEAD>
<body>
     <FORM id="form1"  runat="server" action="index2.aspx">
<asp:TextBox id="MyTextBox" runat="server"></asp:TextBox>
<asp:Button id="MyButton" runat="server" Text="OK"></asp:Button>
     </FORM>
</body>
</HTML>
index2.aspx
------------------------
<script language="C#" runat="server">
void Page_Load()
{
Response.Write (Request.Form["MyTextBox"]);
}
</script>

解决方案 »

  1.   

    你要干吗?要让MyTextBox的内容在另一个页面显示吗?
      

  2.   

    如果这样<FORM id="form1"  action="index2.aspx">就可以提交到其它的页面
      

  3.   

    void MyButton_Click(object sender,EventArgs e)
    {
    Response.Redirect("index2.aspx");
    }
      

  4.   

    如果写成这样的话 <FORM id="form1"  action="index2.aspx">错误就是:类型“TextBox”的控件“MyTextBox”必须放在具有 runat=server 的窗体标记内。
      

  5.   

    那是因为<asp:TextBox id="MyTextBox" runat="server"></asp:TextBox>
    这个控件只能在runat="server的form里,你可以把这个换成
    <FORM id="form1"  runat="server" action="index2.aspx">
    <input type=text name="MyTextBox">
    <input id="MyButton" name="MyButton" type="submit" value="OK" >
    </FORM>
      

  6.   

    你最好在后台代码写
    如下:
    在MyButton_Click()事件里string str=MyTextBox.Text.Trim();
    Response.Write ("index2.aspx?con="+str);在 index2.aspx
    ----------
    void Page_Load()
    {
    Response.Write (Request.Form["con"]);
    }
    就ok了
      

  7.   

    用action是无法递交到另一个页面的,这不不是普通html页,有后台代码的,如果能递交,那么谁来处理这个服务器控件,是一个矛盾,所以不行,只能想其他变通的方法
      

  8.   

    sorry,写错了,是这样
    <FORM id="form1"  action="index2.aspx">
    <input type=text name="MyTextBox">
    <input id="MyButton" name="MyButton" type="submit" value="OK" >
    </FORM>
      

  9.   

    MyButton_Click()事件里string str=MyTextBox.Text.Trim();
    Response.Write ("index2.aspx?con="+str);在 index2.aspx
    ----------
    void Page_Load()
    {
    Response.Write (Request.Form["con"]);
    }
      

  10.   

    http://www.stardeveloper.com/articles/display.html?article=2003061901&page=1
      

  11.   

    http://www.stardeveloper.com/articles/display.html?article=2003061901&page=1http://dotnet.aspx.cc/ShowDetail.aspx?id=ATV1GLXT-65FF-4M82-CT5U-B1J65D3ZN2OK
      

  12.   

    就是把MyTextBox的内容传到另一个页面,不用这么麻烦的,很简单的
      

  13.   

    如果内容是一篇很长的文章呢,用这种方式传肯定不行!!!
    http://www.test.com/index2.asp?text=xxxxx
      

  14.   

    方法一:如gesnpt所说,去掉runat=server属性,不使用服务器控件,换成一般的HTML标签。
           此方法适合于不需要使用服务器控件的场合。方法二:<INPUT type="submit" value="提交" name="b1" onclick="document.all['Form1'].action='index2.aspx';">原因:
    如果 form 标签加了 runat="server" 属性, action 属性设置就不起作用了,ASP.NET生成代码的时候,会把 action 属性设置为本页,如果要转到其他面的话,只能使用脚本控制了。注意:
    如果采用上述这种方法,最好在index2.aspx的Page指令里加入以下语句enableViewState="False" enableViewStateMac="False"
    否则会出现页面缓存状态被破坏的提示。
      

  15.   

    WebForm1.aspx
    ------------------------------------------
    <HTML>
    <HEAD>
    <title>WebForm1</title>
    </HEAD>
    <body >
    <form name="Form1" method="POST" action="WebForm2.aspx" id="Form1">
    <FONT face="宋体">
    <input name="TextBox1" type="text" id="TextBox1"  />
    <input type="submit" name="Button1" value="Button" id="Button1" /></FONT>
    </form>
    </body>
    </HTML>
    ---------------------------------
    WebForm2.aspx.cs    aspx 文件没改
    ---------------------------------
    public class WebForm2 : System.Web.UI.Page
    {
    private string strquery;
    private void Page_Load(object sender, System.EventArgs e)
    {
    // Put user code to initialize the page here
    Response.Write(strquery);
    } #region Web Form Designer generated code
    override protected void OnInit(EventArgs e)
    {
    //
    // CODEGEN: This call is required by the ASP.NET Web Form Designer.
    //
    if(Request.Form["TextBox1"]!=null && Request.Form["TextBox1"] != String.Empty)
    strquery=Request.Form["TextBox1"];
    InitializeComponent();
    base.OnInit(e);
    }

    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {    
    this.Load += new System.EventHandler(this.Page_Load);
    }
    #endregion
    }
      

  16.   

    <FORM id="form1"  runat="server" action="index2.aspx">
    <input type=text name="MyTextBox">
    <input id="MyButton" name="MyButton" type="submit" value="OK" >
    </FORM>
    用客户端控见
      

  17.   

    http://community.csdn.net/Expert/topic/3341/3341912.xml?temp=.2233698
      

  18.   

    呵呵,老问题了,我20天前问了和你同样的问题,答案是:在有runat="server"的表单里设置action是无效的!
      

  19.   

    方法一:用session,application,cache来传都可以,不过慢
    方法二:如果传的值是可以给别人知道的话就很方便
    index.aspx的button_click中
    Response.Redirect("index2.aspx?str="+MyTextBox.Text);
    index.aspx的load中
    Response.Write(Request.QueryString["str"]);
      

  20.   

    去掉 from 里的runat="server"
      

  21.   

    如果这两个页面只是实现你说的传递一个值的话,完全可以只用HTML控件,
      <FORM name="form1"   action="index2.aspx">
    <input name="MyTextBox" >
    <input name="MyButton" Text="OK">     </FORM>第二页,直接接收就可以如果不这样,你也可以用BUTTON的CLICK事件来传
    void MyButton_Click(object sender,EventArgs e)
    {
    Response.Redirect("index2.aspx?text="+MyTextBox.Text.ToString()+"");
    }
      

  22.   

    告诉你一个办法,一定可以
    接受页index2.aspx使用这么一句
    protected override object LoadPageStateFromPersistenceMedium(){ return null;}
    前台index1.aspx代码
    如果使用html控件<INPUT onclick="check();" type="button" value="OK">
    如果还是使用server控件,需要在后台MyButton.Attributes["onclick"]=="check();" ;<script>
    function check()
    {document.form1.action ="index2.aspx";
    //document.form1.target ="hide";//可以自己修改
    document.form1.submit();
    }
      

  23.   

    用button 的Click事件来传,这样你传送的数据不就被人一看就知道了!