locked
How to hide particular resoruce if it is empty RRS feed

  • Question

  • User-715140818 posted

    I am working on globalization project.We are supporting multilingual website.Based on country we have some product offers.If country is germany we don't have that offer.Now in german resource file we have resourcekey and it's value to nothing(no value).Now when we run website we are seeing that blank value.
    Now I want to implement logic if metaresource key is empty just don't show on website.
    For eg: I have link which gets to that offer and text to go that offer is wrapped in literal control.

    </li><

    a style="" href="#"> <asp:Literal runat="server" ID="ltGetOffer" meta:resourcekey="Offer" /></a>!</li

    >

    I have this key defined in resx file called abc.aspx.fr-FR.resx .

    Key     value
    Offer   

    How can I achieve functionality to stop rendering value  if resoruce is empty.


    Wednesday, August 11, 2010 10:45 AM

Answers

  • User1564875471 posted

    You can use "GetLocalResourceObject" page method to lookup resouce value by it's key.

    So in page_load , you can use this code:

     if (GetLocalResourceObject("Offer") == null || GetLocalResourceObject("Offer").ToString() == "")
                ltGetOffer.Visible = false;


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 11, 2010 11:05 AM

All replies

  • User1564875471 posted

    You can use "GetLocalResourceObject" page method to lookup resouce value by it's key.

    So in page_load , you can use this code:

     if (GetLocalResourceObject("Offer") == null || GetLocalResourceObject("Offer").ToString() == "")
                ltGetOffer.Visible = false;


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 11, 2010 11:05 AM
  • User1268001420 posted

    my suggestion would be adding the meta:resource to the literal in the code behind

    depending upon the country

    we can read the name and value from resource file http://www.dreamincode.net/code/snippet1683.htm

    and check if the value is empty add to meta:resource only if value exists


    Wednesday, August 11, 2010 11:10 AM