Howto to use resources from System.Web?

Discussion in 'ASP .Net' started by =?Utf-8?B?ZHBvbXQ=?=, Nov 2, 2006.

  1. I am using the ContentTemplate to extend the CreateUserWizard's
    CreateUserWizardStep with additional controls. For the CreateUserWizardStep
    labels, I would like to keep the automatic localization.
    With Lutz Roeder's .Net Reflector, I found out that System.Web contains the
    text resource System.Web.Resources and I found e.g. the name/value-pair
    CreateUserWizard_DefaultUserNameLabelText=User Name:

    My question here is: how can I bind this resource entry to the label?

    I tried adding
    Text="<%$ Resources:System.Web.resources,
    CreateUserWizard_DefaultUserNameLabelText %>
    to the asp:Label but I get the error message:
    Parser error. The resource object with key
    'CreateUserWizard_DefaultUserNameLabelText' was not found.


    <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName"
    Text="<%$ Resources:System.Web.resources,
    CreateUserWizard_DefaultUserNameLabelText %>" /></td>


    Any help would be greatly appreciated.
    Dieter
     
    =?Utf-8?B?ZHBvbXQ=?=, Nov 2, 2006
    #1
    1. Advertising

  2. Hello Dieter,

    From your description, you're using the ContentTemplate to customize the
    CreateUserWizard control and also want to utilize the existing localizaed
    resources of the CreateuserWizard control. However, when you try using the
    <%$ Resources:... %> expression to reference the resource, it not work,
    correct?

    As for this issue, it is due to the natural limitation of the <%$ Resource
    %> expression, this expression just identical to the following methods in
    page:

    HttpContext.GetGlobalResourceObject Method

    HttpContext.GetLocalResourceObject Method

    Both of the two methods(also the <%$ Resource expression %>) can only
    reference resource items defined within the current ASP.NET application's
    LocalResource or GlobalResource, but can not reference resource items in
    external assemblies. Actually, through the reflector diassembled code, you
    can find that the built-in CreateUserWizard control is using the following
    code to load resource string from assembly:

    ==================
    ResourceManager rm = new ResourceManager("System.Web",
    typeof(CreateUserWizard));

    rm.GetString(keyname, Culture);

    ===================

    Therefore, if you want to load any localization resource objects from
    external assembly, you need to use ResourceManager to do it
    programmatically.


    Please feel free to let me know if you have anything unclear or any other
    questions here.

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead



    ==================================================

    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    ications.



    Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 1 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions or complex
    project analysis and dump analysis issues. Issues of this nature are best
    handled working with a dedicated Microsoft Support Engineer by contacting
    Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/subscriptions/support/default.aspx.

    ==================================================



    This posting is provided "AS IS" with no warranties, and confers no rights.
     
    Steven Cheng[MSFT], Nov 3, 2006
    #2
    1. Advertising

  3. Hello Steven,

    thanks for the feedback!

    > ResourceManager rm = new ResourceManager("System.Web",
    > typeof(CreateUserWizard));


    using typeof(CreateUserWizard).Assembly (with ".Assembly") instead, will
    make it comilable.

    The solution you have provided works great. Thanks a lot!

    Best regards,
    Dieter
     
    =?Utf-8?B?ZHBvbXQ=?=, Nov 5, 2006
    #3
    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. Matt
    Replies:
    2
    Views:
    889
    Matt Getting
    Jul 24, 2003
  2. Russell E. Owen
    Replies:
    0
    Views:
    737
    Russell E. Owen
    Sep 8, 2006
  3. Nathan Sokalski
    Replies:
    5
    Views:
    1,082
    Gaurav Vaish \(www.Edujini-Labs.com\)
    Jan 10, 2007
  4. Nathan Sokalski
    Replies:
    4
    Views:
    340
    Nathan Sokalski
    Dec 21, 2006
  5. Nathan Sokalski
    Replies:
    4
    Views:
    378
    Nathan Sokalski
    Dec 21, 2006
Loading...

Share This Page