localized asp:label w/nested control bug?

A

Anson Goldade

I think I may have run into an issue with the asp.net lable control. Take
the following code

<asp:label runat="server" id="txtTextLabel"
associatedcontrolid="txtText" meta:resourcekey="txtTextLabel">
<asp:textbox runat="server" id="txtText"></asp:textbox>
</asp:label>

Create the app local resource file with a single entry (e.g. Name:
"txtTextLabel.Text" Value: "Testing resource").

Now run the page. You should get the following error "Unable to find
control with id 'txtText' that is associated with the Label 'txtTextLabel'."
Now remove the meta:resourcekey="txtTextLabel" attribute from the asp:label
control and it works fine. Is there a reason why controls can't be nested
when using localized resources with labels? Thanks for your assistance in
advance.
 
A

Anson Goldade

Dave,

Nesting inside label tags is supported within HTML. According to the 4.0
spec any inline elements are supported as child elements to a label. The way
to get the asp:label control to render as a label tag instead of a span is to
set the associatedcontrolid property as in the sample code. The nesting is
not the problem, the problem is the nesting when used in conjunction with the
localized resource files.

The reason we want to nest them is so that we can apply the style
information we want across the label to get the flowing working properly. If
the nesting isn't going to work, then we have to wrap all of the label,
input, validation control pairs in a div just to get the layout and flow
working properly.

Also, usually, if you aren't able to nest something within another control,
you won't get the option in intellisense. For nesting the textbox control
in the label, you do get the intellisense meaning that it's been defined in
the schema that nesting is allowed/supported ... at least I believe that's
how it works.

The ultimate resolution to my question would be for me to understand if this
is a bug or if it's intentionally not supported. I need to make a decision
about wether we should work with support to resolve on just bite the bullet
and wrap everything in a div.

Thanks for your feedback.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,142
Latest member
arinsharma
Top