我把它理解为纯HTML:

<label for="txtPais">Pais:</label>    
<input name="ctl00$ContentPlaceHolder1$txtPais" type="text" id="ctl00_ContentPlaceHolder1_txtPais" class="textInput" />

在Visual Studio中的实际代码中,我有以下内容:

<label for="txtPais">Pais:</label>    
<asp:TextBox ID="txtPais" runat="server" CssClass="textInput"></asp:TextBox>

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

推荐答案

您应该使用HAACK上this blog post中详细说明的<asp:Label...>

<asp:Label id="label" AssociatedControlId="txtPais" Text="Pais:" runat="server" />
<asp:TextBox id="txtPais" runat="server" CssClass="textInput" />

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

Asp.net相关问答推荐

如何在 ASP.Net Core 中验证上传的文件

如何在没有 Select 按钮的情况下在 GridView 中实现全行 Select ?

任何人都有解决 Internet Explorer 上剩余 n 项问题的 idea 吗?

说服遗留应用程序 VB6 开发人员切换到 C#

如何判断一个IP地址是否是私有的?

如何从 web.config 中读取系统值并在 ASP.NET MVC C# 方法中使用

HttpContext.Current.Request.IsAuthenticated 和 HttpContext.Current.User.Identity.IsAuthenticated 有什么区别?

倒带请求正文流

在 IIS 上托管 ASP.NET 5 项目

如何在asp.net中获取应用程序路径?

GMT 和 UTC 一样吗?

Azure Functions 中的 DI

Fiddler 没有从 ASP.NET 网站嗅探 SOAP 流量

根据条件更改 GridView 行 colored颜色

GridView 按代码隐藏列

如何使用 ConfigurationManager.AppSettings

字体真棒里面asp按钮

如何在服务器控件属性中使用 ASP.NET <%= 标签?

使用 jQuery 从 asp:RadioButtonList 读取选定的值

MVC4 中 Global.asax.cs 页面中的问题