Guille Brossi
Guille Brossi

Reputation: 35

ASP.NET Localize

A simple question. I have a site with localization (with .resx files) and when i need to insert localized text i use a code like this:

<asp:Localize Text="<%$ Resources: MyResource, Default_BannerHomeTitle %>" runat="server">SOME_TEXT_HERE_OR_NOT?</asp:Localize>

The question is if anyone knows what's the utility of the text between the asp:Localize tag -> "SOME_TEXT_HERE_OR_NOT?"

The real value come from the .resx file and the text "SOME_TEXT_HERE_OR_NOT?" is obviusly deleted when the page is rendered.

Is this text used in some situation? or is never used?

thanks in advance!

Upvotes: 0

Views: 179

Answers (1)

Cᴏʀʏ
Cᴏʀʏ

Reputation: 107606

The Text property you are setting inline and the text you type between the tags is effectively the same thing. You should be using one or the other, there's no point in setting both.

The Localize control is just a subclass of the Literal control. Technically, the text you type between the tags is interpreted as its own separate Literal control, a "parsed sub-object". When the Localize control is created, its Text property is set to the value of the sub-object's Text property. However, setting the Text property explicitly on the Localize control will take precedence over anything typed between the tags.

Upvotes: 2

Related Questions