他们是否有任何可以呈现<label>的asp网络服务器控件?标签?

Is their any asp net server control which could render lt;labelgt; tag?(他们是否有任何可以呈现lt;labelgt;的asp网络服务器控件?标签?)

本文介绍了他们是否有任何可以呈现<label>的asp网络服务器控件?标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想渲染一个 <label> 标签.但是想要在渲染时设置它的一些属性,比如 for 和 text 值.

I want to render a <label> tag. But want to set some of it's properties while it's rendering like for and text value.

实际上我真正的问题是我想将标签与单选按钮相关联,这是我目前拥有的代码:

Actually my real problem is I want to associate a label with a radio button and this is the code so far I have:

<asp:RadioButton ID="Option4" GroupName="A" runat="server" />

<label for='<%=Option4.ClientID %>' id="lblOption4" runat="server">4</label>

但此代码的问题在于它无法正常工作并呈现 for 属性的值,即 <%=Option4.ClientID %>.:-(

But the problem with this code is that it is not working and rendering the for attibute's value as it is i.e. <%=Option4.ClientID %>. :-(

他们是否有任何会呈现标签的asp网络服务器控件?

Is their any asp net server control which would render tag?

由于某些 CSS 限制,我不想设置单选按钮的 Text 属性,所以请不要给出为什么不设置单选按钮的 Text 属性等答案.

I don't want to set the Text property of the radio button due to some CSS limitations so plz do not give answers like why don't you set the Text property of the radio button.

推荐答案

如果这是.NET 2.0或更高版本,则使用ASP.NET LABEL控件.

if this is .NET 2.0 or later, then use the ASP.NET LABEL control.

<asp:RadioButton ID="Option4" GroupName="A" runat="server" />
<asp:Label AssociatedControlId="Option4" Text="4" runat="server" />

这篇关于他们是否有任何可以呈现&lt;label&gt;的asp网络服务器控件?标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:他们是否有任何可以呈现&lt;label&gt;的asp网络服务器控件?标签?

基础教程推荐