Is their any asp net server control which could render <label> tag?

六眼飞鱼酱① 提交于 2019-12-10 10:03:49

问题


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>

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 %>. :-(

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

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.


回答1:


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" />



回答2:


If this is to ultimately handle accessiblity issues you could try the following tutorial: Creating an Accessible LABEL control in ASP.NET



来源:https://stackoverflow.com/questions/1953511/is-their-any-asp-net-server-control-which-could-render-label-tag

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!