Test.aspx
<%@ Page Language="C#" CodeFile="Test.aspx.cs" Inherits="_Default" Debug="true" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"></script><html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Title</title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
        </div>
    </form>
</body>
</html>
CS
using System;/// <summary>
/// Class1 的摘要说明
/// </summary>public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Write(Request.Form["Content"]);
    }
}<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Untitled Page</title>
</head>
<body>
    <form action="Test.aspx" method="post" id="form1">
        <textarea rows="10" cols="40" id="Content"> </textarea>
        <input id="Button1" type="submit" value="提交" />
        <br />
    </form>
</body>
</html>--------------
所有页面代码就是这样,却获取不到提交过来的值?问了三天没有答案呵呵

解决方案 »

  1.   

    Asp.net和Asp差别还是很大的。这样写结构上就有问题。改成这样
    <%@ Page Language="C#" CodeFile="Test.aspx.cs" Inherits="_Default" Debug="true" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"></script><html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Title</title>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
            <textarea rows="10" cols="40" id="Content" runat="server"> </textarea>
            <input id="Button1" type="submit" value="提交" />
            <br />
            </div>
        </form>
    </body>
    </html>C# codeusing System;/// <summary>
    /// Class1 的摘要说明
    /// </summary>public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Write(Content.Text);
        }
    }作为Content控件必须runat="server",就可以直接用Id获取值了。
      

  2.   

    做为网页的常识..控件提交认的是name,而不是id<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Untitled Page</title>
    </head>
    <body>
        <form action="Test.aspx" method="post" id="form1">
            <textarea rows="10" cols="40" id="Content" name="Content"> </textarea>
            <input id="Button1" type="submit" value="提交" />
            <br />
        </form>
    </body>
    </html>