Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET - meta:ResourceKey vs <%$ Resources:MyKey %>

Tags:

asp.net

what's the difference between assigning text to a Label using meta:ResourceKey and Text="<%$ Resources:MyKey %>". i get the same results using both methods.

like image 945
400_the_cat Avatar asked Jul 03 '10 04:07

400_the_cat


1 Answers

The first form is called an implicit resource expression, the second form is an explicit resource expression.

They may give the same result for a single property. However, the implicit meta:ResourceKey has some advantages in that if there are several resourced property definitions in the local resource file, all of them will be applied with just that single declaration. The disadvantage is that it has to be from the "local" resource file, i.e. the resource file for that page.

If you use the explicit property assignment of Text="<%$ Resources:MyKey %>", you'll need to add that code for every property value you want to fetch from the resource file. However, the advantage is that you can specify a filename parameter and fetch the resource from a global resource file.

Here's a reference.

like image 89
womp Avatar answered Sep 26 '22 09:09

womp