When I started localizing a website the first time, I just did the localization like this:
<%= Resources.ResourceFile.ResourceName %>
and it seems to work perfectly fine. However, the ReSharper 5.0 Beta does it like this:
<asp:Localize Text="<%$ Resources: ResourceFile, ResourceName %>" runat="server">
Value
</asp:Localize>
Does it matter which way it gets done?
Also, why does ReSharper keep the original text inside the localize control? I thought it was there in case the Value inside the Resource file was empty, it could show the "default" text. This does not appear to be the case. Is it safe to remove it and just self close the localize control?
well, you can't use the <%= %> server tag on a asp server control.
so
<asp:Localize Text="<%= Resources.ResourceFile.ResourceName %>" runat="server">
Value
</asp:Localize>
will result in a compilation error.
Unfortunately you cannot pass dynamic data to server control properties unless it is databound where you can apply the <%# %>
server tag, for example:
<asp:Repeater runat="server">
...
<asp:Localize Text="<%# Resources.ResourceFile.ResourceName %>" runat="server">
Value
</asp:Localize>
...
</asp:Repeater>
You can always move this to the codebehind but that sucks.
the <%$ %>
'thing' works however if you go by it prepare to enter maintenance hell (unless of course we are talking about a 3 page application...)
Personally i use the <%= %>
and i never use re-sharper to globalize/localize my apps.
Also, i've never used the <asp:Localize />
server control and i've had no problems...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With