Home All Groups Group Topic Archive Search About

localized asp:label w/nested control bug?

Author
30 Oct 2007 4:08 PM
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.

Author
30 Oct 2007 5:05 PM
Dave Bush
You can't nest an asp:textbox in an asp:label.  Put them beside each other
and I bet it works.

-----Original Message-----
From: Anson Goldade [mailto:AnsonGold***@discussions.microsoft.com]
Posted At: Tuesday, October 30, 2007 12:08 PM
Posted To: microsoft.public.dotnet.framework.aspnet.webcontrols
Conversation: localized asp:label w/nested control bug?
Subject: localized asp:label w/nested control bug?

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.
Author
30 Oct 2007 6:17 PM
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.

Show quote
"Dave Bush" wrote:

> You can't nest an asp:textbox in an asp:label.  Put them beside each other
> and I bet it works.
>
> -----Original Message-----
> From: Anson Goldade [mailto:AnsonGold***@discussions.microsoft.com]
> Posted At: Tuesday, October 30, 2007 12:08 PM
> Posted To: microsoft.public.dotnet.framework.aspnet.webcontrols
> Conversation: localized asp:label w/nested control bug?
> Subject: localized asp:label w/nested control bug?
>
> 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.
>
>
Author
30 Oct 2007 6:40 PM
Dave Bush
Hmm, guess I learned something new today.


-----Original Message-----
From: Anson Goldade [mailto:AnsonGold***@discussions.microsoft.com]
Posted At: Tuesday, October 30, 2007 2:17 PM
Posted To: microsoft.public.dotnet.framework.aspnet.webcontrols
Conversation: localized asp:label w/nested control bug?
Subject: Re: localized asp:label w/nested control bug?

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.

Show quote
"Dave Bush" wrote:

> You can't nest an asp:textbox in an asp:label.  Put them beside each
> other
> and I bet it works.
>
> -----Original Message-----
> From: Anson Goldade [mailto:AnsonGold***@discussions.microsoft.com]
> Posted At: Tuesday, October 30, 2007 12:08 PM
> Posted To: microsoft.public.dotnet.framework.aspnet.webcontrols
> Conversation: localized asp:label w/nested control bug?
> Subject: localized asp:label w/nested control bug?
>
> 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.
>
>
Author
30 Oct 2007 9:19 PM
Dave Bush
BTW, since the TextBox inside the Label thing doesn't render in design
view.  I suspect no one at MS expected you to use it in this way (even
though technically, it IS legal.)

I'll be interested to hear how far you get w/ MS.

-----Original Message-----
From: Dave Bush [mailto:davemb***@dmbcllc.com]
Posted At: Tuesday, October 30, 2007 2:41 PM
Posted To: microsoft.public.dotnet.framework.aspnet.webcontrols
Conversation: localized asp:label w/nested control bug?
Subject: Re: localized asp:label w/nested control bug?

Hmm, guess I learned something new today.


-----Original Message-----
From: Anson Goldade [mailto:AnsonGold***@discussions.microsoft.com]
Posted At: Tuesday, October 30, 2007 2:17 PM
Posted To: microsoft.public.dotnet.framework.aspnet.webcontrols
Conversation: localized asp:label w/nested control bug?
Subject: Re: localized asp:label w/nested control bug?

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.

Show quote
"Dave Bush" wrote:

> You can't nest an asp:textbox in an asp:label.  Put them beside each
> other
> and I bet it works.
>
> -----Original Message-----
> From: Anson Goldade [mailto:AnsonGold***@discussions.microsoft.com]
> Posted At: Tuesday, October 30, 2007 12:08 PM
> Posted To: microsoft.public.dotnet.framework.aspnet.webcontrols
> Conversation: localized asp:label w/nested control bug?
> Subject: localized asp:label w/nested control bug?
>
> 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.
>
>

AddThis Social Bookmark Button