偶初次使用masterPage,发现引用masterPage的页面上所有的asp元素的名称及id都被加上一长串前缀,如下:         <asp:Label ID="Label1" runat="server" Text="开始时间"></asp:Label>
        <asp:TextBox ID="Txt_STime" runat="server" Width="112px"></asp:TextBox>运行后生成的html脚本变为:        
<span id="_ctl0_ContentPlaceHolder1_Label1">开始时间</span>
<input name="_ctl0:ContentPlaceHolder1:Txt_STime" type="text" id="_ctl0_ContentPlaceHolder1_Txt_STime" style="width:112px;" />;
 
这是什么原因啊!!!

解决方案 »

  1.   

    你把    <asp:Label ID="Label1" runat="server" Text="开始时间"></asp:Label>
            <asp:TextBox ID="Txt_STime" runat="server" Width="112px"></asp:TextBox>这个页面理解成用户控件就可以了
      

  2.   

    但是如果没有引用mastePage,它们的id值就不会发生改变,这是为什么呀
      

  3.   

    <asp:Label ID="Label1" runat="server" Text="开始时间"></asp:Label>
            <asp:TextBox ID="Txt_STime" runat="server" Width="112px"></asp:TextBox>
    没有引用masterPage:运行后生成的html脚本:
            <span id="Label1">开始时间</span>
            <input name="Txt_STime" type="text" value="2006-4-3 17:23:17" id="Txt_STime" style="width:112px;" />引用masterPage:运行后生成的html脚本:
           <span id="_ctl0_ContentPlaceHolder1_Label1">开始时间</span>
            <input name="_ctl0:ContentPlaceHolder1:Txt_STime" type="text" id="_ctl0_ContentPlaceHolder1_Txt_STime" style="width:112px;" />;
      

  4.   

    你在masterpage中,当然是作为masterpage的一个子页面了。用clientid可以精确获得其最后输出为html的id.
      

  5.   

    谢谢楼上的,不过<asp:TextBox ID="Txt_STime" runat="server" Width="112px"></asp:TextBox>里面没有clientid属性项
      

  6.   

    没有为什么.
    MS在输出html的时候就是这么干的.
    就好比DataGird里的子控件,前面不加一串怎么能防止ID重复呢.