Reputation: 1299
I have created my own DBResourceProvider which gets texts from a database in a given language. I can set a label problematically by writing
Label1.Text = Text.Slogan;
In the webpage itself I can write
<asp:Label ID="Label1" runat="server" Text="<%$ Resources:MyDbResource, Slogan %>"></asp:Label>
I am trying to figure out a way that I can have that last line of code strongly typed. Is that even possible?
UPDATE:
I generate this code to access the resources:
public static String Slogan { get{return getText("Slogan") ;} }
And this is my getText method:
public static string getText(string key)
{
return HttpContext.GetGlobalResourceObject("Global", key).ToString();
}
If you think I included to little of my code here, give me a comment and I'll bring more code to the table!
Upvotes: 1
Views: 251
Reputation: 1086
In your .aspx file just write:
<html>
<title></title>
<body>
Our slogan is: <%= Text.Slogan %>
</body>
</html>
Upvotes: 2