TinoNL
asked on
How can I access values in the Resource .resx file that is attached to custom control?
I have a directory called Controls. This folder contains all my custom controls. To keep things nice and tidy, I also placed my resource files there. These resource files don't have to be application wide available through the app_GlobalResources folder, but only to the custom control.
There is a (simple) custom control called FooterControl.vb. When I add a resource file with the name FooterControl.resx, this is displayed as a child of the footercontrol.
In the Resource file, there is a value for btnSave, that contains the translation that should be displayed on the Text label. But when I want to assign the value I get stuck. Resources.FooterControl.bt nSave doesn't work.
There is a (simple) custom control called FooterControl.vb. When I add a resource file with the name FooterControl.resx, this is displayed as a child of the footercontrol.
In the Resource file, there is a value for btnSave, that contains the translation that should be displayed on the Text label. But when I want to assign the value I get stuck. Resources.FooterControl.bt
<DefaultProperty("Text"), ToolboxData("<{0}:FooterControl runat=server></{0}:FooterControl>")> _
Public Class FooterControl
Inherits WebControl
Implements INamingContainer
Implements IComponent
Protected Overrides Sub CreateChildControls()
Dim myButton As New Button
myButton.Text = Resources.FooterControl.btnSave
Me.Controls.Add(myButton)
End Sub
End Class
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Nah; it looks like the globalresourceobject only works when your resx files reside in the app_GlobalResources folder?
But it brought me the idea to explore the class view a little bit further and found the solution myself.
Thanks for leading me this way.
But it brought me the idea to explore the class view a little bit further and found the solution myself.
Thanks for leading me this way.
My.Resources.FooterControl.btn_Save
ye ... that's why we called them gloabal resource ... . i am glad that you find a way .. all the best
ASKER
Thanks for the help man!
ASKER
HttpContext.GetGlobalResou
It gives the error:
Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "Resources.FooterControl.r
So then I tried approaching the file through the local object:
HttpContext.GetLocalResour
It throws the error:
The relative virtual path 'FooterControl' is not allowed here.