还是要放在.cs中写。postback会消失。是因为加了 !this.IsPostBack. 去掉就好了。runat="Server"是asp.net解释的。在客户端生成的html中包含runat="server"是没有用的。

解决方案 »

  1.   

    按楼上的意思,就是点击button先执行一遍动态添加的代码,在PAGE—LOAD里再做一遍?
      

  2.   

    可以考虑运用JS来动态生成控件。而要在隐藏代码中获取其值,可以用hidden来传送!
      

  3.   

    to:可以考虑运用JS来动态生成控件。而要在隐藏代码中获取其值,可以用hidden来传送!
    原来就是这样想的,但是用了RESPONSE.FORM[HIDDEN1]有错误产生
      

  4.   

    <script>   
    var   inputNum   =   0; 
    function   create()   
    {             
    var   str   =   ""; 
    str   +=   "<input id=id"+inputNum+"  type=text  name=text"+inputNum+">"; 
    inputNum++;
    str   +=   "<input   type=text   name=text"+inputNum+">"; 
    inputNum++;
    str   +=   "<input   type=radio  name=text"+inputNum+">"; 
    inputNum++;
    str   +=   "<input   type=text   name=text"+inputNum+"><br/>"; 
    ice.innerHTML   =   ice.innerHTML   + str;   
    }
    function setvalue()
    {
    document.getElementById("myHidden").value = document.getElementById("id0").value

    </script>
    ....
    <tr>
    <td>
    <asp:Label id="Label3" runat="server" onclick="create()">Label</asp:Label>
    <input type=hidden id=myHidden runat=server>
    </td>
    </tr>
    ....
    <asp:Button id="Button2" runat="server" Text="Button"></asp:Button>后台加载时添加:
    Button2.Attributes.Add("onclick", "setvalue()");
    后台Button2的click事件中获取值:
    string text0_Value = this.myHidden.Value;