locked
Localizing text inside <div> or any regular inner text RRS feed

  • Question

  • User662461862 posted

    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 ?

    Wednesday, July 18, 2007 8:20 AM

Answers

  • User1622957740 posted

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

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 18, 2007 1:46 PM

All replies

  • User1622957740 posted

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

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 18, 2007 1:46 PM
  • User764555827 posted

     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 

    Wednesday, July 18, 2007 5:57 PM