<asp:Label ID="txtA" runat="server" Visible="false">时间:
<asp:TextBox ID="txtB" runat="server" ></TextBox>
</asp:Label>
if (!this.IsPostBack)
{
    txtA.Visible=true;
}初次可以显示"时间:...";
但再次提交就没有了;
但是写成下边的形式就可以:<asp:Label ID="txtA" runat="server" Visible="false">时间:
</asp:Label>
<asp:TextBox ID="txtB" runat="server" Visible="false">></TextBox>
if (!this.IsPostBack)
{
    txtA.Visible=true;
    txtB.Visible=true;
}为什么?

解决方案 »

  1.   

    再次提交时,页面已经刷新,他的visible又变成了false,所以不显示
    if (!Page.IsPostBack)
    {
        txtA.Visible=true;
        txtB.Visible=true;
    }
      

  2.   

    因为后台没有对TextBox 的定义,你需要访问repeater,然后通过repeater访问你的TextBox 或者通过FindControl()方法.....
      

  3.   

    <asp:Label ID="txtA" runat="server" Visible="false">时间:
    <asp:TextBox ID="txtB" runat="server" ></TextBox>
    </asp:Label>
    这样的"嵌套",即使能过,也强烈反对这样的写法.
      

  4.   

    我建议你不要用Label  用Literal控件最好  Label会最终解析为Span  而Literal什么也不输出你还可以在后台设置Literal的Text属性="<asp:TextBox>..</..> "  放什么都可以