In the ASP.NET application & lt; Label & gt;
What is the best way to use tags? I want it to be valid XHTML, accessible and usable.
I think the optimal way is:
& lt; Label = "username" & gt; Username: & lt; / Labels & gt; & Lt; Input type = "text" id = "user name" runat = "server" />
But if the above code is in an ASP.NET user control, the input id will change, which means the "for" attribute for labels is useless. I can control the label tag one server and it can set the "to-do" attribute for the code (username id. Client id) but it seems that there is a lot of work for such a simple thing.
I have also seen this HTML used in the past:
& Lt; / Labels & gt;
What is the optimal approach?
I Note that you can also nest other tags within the label control you want: & lt; Asp: label ... associate control id = "user name" ... & gt;
Control for this & lt; Label & gt;
is sung in the form of tags and set the attribute to fit appropriately.
& lt; Asp: Label ID = "UsernameLabel" Text = "Username:" AssociatedControlID = "UsernameTextBox" runat = "server" & gt; & Lt; ASP: Textbox ID = "UsernameNext Box" Runat = "Server" /> & Lt; / ASP: Labels & gt;
Comments
Post a Comment