How to use label for in an ASP.Net webform?(如何在 ASP.Net 网络表单中使用标签?)
问题描述
我把它当作纯 HTML:
I get this as pure HTML:
<label for="txtPais">Pais:</label>
<input name="ctl00$ContentPlaceHolder1$txtPais" type="text" id="ctl00_ContentPlaceHolder1_txtPais" class="textInput" />
在我在 Visual Studio 中的实际代码中,我有这个:
In my actual code in Visual Studio I have this:
<label for="txtPais">Pais:</label>
<asp:TextBox ID="txtPais" runat="server" CssClass="textInput"></asp:TextBox>
我将如何为该文本框应用标签?
How would I apply a label for this textbox?
推荐答案
您应该使用 <asp:Label...>
如这篇关于 Haacked 的博文
<asp:Label id="label" AssociatedControlId="txtPais" Text="Pais:" runat="server" />
<asp:TextBox id="txtPais" runat="server" CssClass="textInput" />
这应该与被转换的 ID 正确转换.
This should convert correctly with the ID being converted.
这篇关于如何在 ASP.Net 网络表单中使用标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!