locked
I cannot read from resource files RRS feed

  • Question

  • User-375223641 posted

    Hello,

    I'm developing a binligual website(Arabic/English). I'm using resources files to display messages in lables like this

    <asp:Label ID="lblSongs_title" runat="server" meta:resourcekey="lblSongs_titleResource1" ></asp:Label>


    I need to change the labe text from code behind, but I don't know how to do this?? I tried this code

    System.Threading.Thread.CurrentThread.CurrentCulture = ci;
            System.Threading.Thread.CurrentThread.CurrentUICulture = ci;
            this.InitializeCulture();
            ResourceManager resman = new ResourceManager("about.resx", Assembly.GetExecutingAssembly());
            
            lblSongs_title= resman.GetString("lblSongs_title.Text", ci);

    but it did not work.

    Thank you

    Thursday, December 23, 2010 6:04 AM

All replies

  • User-231977777 posted

    hi

    you need to use :

    GetLocalResourceObject ("Control.Property").ToString();

    please take alook at : http://msdn.microsoft.com/en-us/library/ms227982.aspx

    hope this helps

    Thursday, December 23, 2010 7:07 AM
  • User-1685971342 posted

    Hi,

    See if this helps.

    <Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _Friend Shared ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManagerGet If Object.ReferenceEquals(resourceMan, Nothing) Then 

    resourceMan = temp 

    Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("Resources.TextMessages", Global.System.Reflection.[Assembly].Load("App_GlobalResources"))

    End If 

    Return resourceMan

    End Get  

    End Property

     Private Shared resourceMgr As ResourceManager

    resourceMgr = Resources.TextMessages.ResourceManager

    lbl.text =resourceMgr.GetObject(name)

    Thursday, December 23, 2010 7:31 AM
  • User-375223641 posted

    I'm using VS2005 not Frame work 4,GetLocalResourceObject needs 2 arguments

    HttpContext.GetLocalResourceObject(virtualpath,"control.Text").ToString();

    but I don't know what is the virtual path?


    Thursday, December 23, 2010 7:39 AM
  • User-519136805 posted

    Hi ,

    Here is sample code for you :

    Button1.Text = GetLocalResourceObject("key").ToString();


    GetLocalResourceObject methods do not need 2 parameters , LocalResource will get automatically get reference of resource files generated for that page.

    I hope this will help you

    Saturday, January 1, 2011 1:09 AM