Localizing text inside <div> or any regular inner text

Last post 07-18-2007 5:57 PM by aweil. 2 replies.

Sort Posts:

  • Localizing text inside <div> or any regular inner text

    07-18-2007, 8:20 AM
    • Member
      41 point Member
    • Mourad
    • Member since 03-10-2007, 3:53 PM
    • Posts 107

    Hello,

    How do I tel VS to generate resources for any inner text, e.g.:

    <div> Hello ! </div>

    do I have to put all text inside LABEL tags ?

  • Re: Localizing text inside <div> or any regular inner text

    07-18-2007, 1:46 PM
    Answer
    • Participant
      1,431 point Participant
    • rstrahl
    • Member since 08-20-2003, 1:08 PM
    • Paia, Hawaii
    • Posts 277
    • ASPInsiders
      TrustedFriends-MVPs

    You can't localize purely static text - at least not from the server side (you can do it from the client side with JavaScript but it's ugly).

    So yes you'll want to use labels or any other controls type around all static text.

    Alternately you can also do something like this:

    <div> <%= this.GetLocalResourceObject("HelloLabel") %></div>

    although there are a few caveats to that scenario:

    http://www.west-wind.com/WebLog/posts/114530.aspx

    Hope this helps.

    +++ Rick ---

    Rick Strahl
    West Wind Technologies
    Making waves on the Web
    www.west-wind.com/weblog
  • Re: Localizing text inside <div> or any regular inner text

    07-18-2007, 5:57 PM
    • Member
      725 point Member
    • aweil
    • Member since 09-09-2005, 6:57 PM
    • Paris, France
    • Posts 118

     Hi Mourad,

    It may not be so clean (some overhead at run time), but you can replace your <div> with a <div runat="server">, which is quite easy to to project-wide with a "search and replace"... 

    Hope this helps,

    Arnaud 

    Microsoft .net Training and Consulting
    http://www.dreamdotnet.com/
    Microsoft .net 3.0 Training and Consulting
Page 1 of 1 (3 items)