• λ我爱Aspx >> Asp.Net >> ASP.NET 2.0服务器控件与form runat=server标记
  • ASP.NET 2.0服务器控件与form runat=server标记

  • :未知  Դ:非寒日志  :2007-4-21 0:50:51  ؼ:.net,asp.net,asp
  • {

    }

    protected void Button1_Click(object sender, EventArgs e)

    {

    Response.Write("<li>TextBox1.Text = " + TextBox1.Text);

    Response.Write("<li>Request.Params = " + Request.Params[TextBox1.UniqueID]);

    }

    protected void Page_Load(object sender, EventArgs e)

    {

    Response.Write("<li>TextBox1.Text = " + TextBox1.Text);

    Response.Write("<li>Request.Params = " + Request.Params[TextBox1.UniqueID]);

    if (!IsPostBack)

    {

    TextBox1.Text = "《ASP.NET2.0应用开发技术》";

    }

    }

    </script>

    <html xmlns="http://www.w3.org/1999/xhtml">

    <head runat="server">

    <title>VerifyRenderingInServerForm</title>

    </head>

    <body>

    <asp:TextBox ID="TextBox1" runat="server" Width="600px"></asp:TextBox>

    <form id="form1" runat="server">

    <asp:Button ID="Button1" runat="server" OnClick="Button1_Click"

    Text="提交" />

    </form>

    </body>

    </html>

    因此,在一般情况下,不要将服务器控件移到<form runat=server></form>的标记之外

    4,如何强制将服务器控件放入<form runat=server></form>的标记之间

    有些服务器控件可以不放在<form runat=server></form>的标记之间,如Label控件,但如果需要强制将它放<form runat=server></form>的标记之间,可以使用下面的方法:

    protected void Label1_PreRender(object sender, EventArgs e)

    {

    this.VerifyRenderingInServerForm(Label1);

    Ҷƪл˵?
  • һƪ通过避免10 个常见 ASP.NET 缺陷使网站平稳运行
    һƪ使用 C# .NET 写入事件日志