如何在ASP.Net webform中使用label?

35 asp.net label webforms

我认为这是纯HTML:

<label for="txtPais">Pais:</label>    
<input name="ctl00$ContentPlaceHolder1$txtPais" type="text" id="ctl00_ContentPlaceHolder1_txtPais" class="textInput" />
Run Code Online (Sandbox Code Playgroud)

在我在Visual Studio中的实际代码中,我有这样的:

<label for="txtPais">Pais:</label>    
<asp:TextBox ID="txtPais" runat="server" CssClass="textInput"></asp:TextBox>
Run Code Online (Sandbox Code Playgroud)

如何为此文本框应用标签?

Chr*_*isF 69

您应该使用本博客文章中关于Haacked的<asp:Label...>详细信息

<asp:Label id="label" AssociatedControlId="txtPais" Text="Pais:" runat="server" />
<asp:TextBox id="txtPais" runat="server" CssClass="textInput" />
Run Code Online (Sandbox Code Playgroud)

这应该与正在转换的ID正确转换.