localized asp:label w/nested control bug?

Discussion in 'ASP .Net Web Controls' started by Anson Goldade, Oct 30, 2007.

  1. 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.
    Anson Goldade, Oct 30, 2007
    #1
    1. Advertising

  2. 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.

    "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:]
    > 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.
    >
    >
    Anson Goldade, Oct 30, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Piotr Strycharz

    Customizing localized applications

    Piotr Strycharz, Aug 20, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    317
    clintonG
    Aug 20, 2004
  2. Shapper
    Replies:
    2
    Views:
    729
    Scott Mitchell [MVP]
    May 7, 2005
  3. =?Utf-8?B?SGVua2U=?=

    Adding a control to a localized ASP .NET 2.0 application

    =?Utf-8?B?SGVua2U=?=, Aug 8, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    339
    =?Utf-8?B?SGVua2U=?=
    Aug 8, 2005
  4. John H
    Replies:
    0
    Views:
    106
    John H
    May 22, 2006
  5. Knut Krueger
    Replies:
    8
    Views:
    263
    Knut Krueger
    Aug 20, 2013
Loading...

Share This Page