{"id":46,"date":"2011-10-14T11:12:00","date_gmt":"2011-10-14T11:12:00","guid":{"rendered":"https:\/\/wdev-blog.azurewebsites.net\/index.php\/2011\/10\/14\/localizing-asp-net-tips\/"},"modified":"2011-10-14T11:12:00","modified_gmt":"2011-10-14T11:12:00","slug":"localizing-asp-net-tips","status":"publish","type":"post","link":"http:\/\/panahy.nl\/index.php\/2011\/10\/14\/localizing-asp-net-tips\/","title":{"rendered":"Localizing ASP.NET Tips"},"content":{"rendered":"<\/p>\n<p>There are two kind of localizations:<\/p>\n<\/p>\n<ul>\n<li>Local resources are specific to a page.<\/li>\n<li>Global resources are shared throughout the site<\/li>\n<\/ul>\n<p>If your site contains many folders, you might have an <b>App_LocalResources<\/b> subfolder in each folder of your site.<\/p>\n<p><\/p>\n<p>&lt;asp:Button ID=&quot;ButtonFind&quot; runat=&quot;server&quot; Text=&quot;Find&quot; CssClass=&quot;submitButton&quot; <b>meta:resourcekey=&quot;ButtonFindResource1&quot;<\/b> \/&gt;<\/p>\n<p>&lt;asp:Localize ID=&quot;LabelTitle&quot; runat=&quot;server&quot; <b>Text<\/b>=&quot;Customer Lookup&quot;<b> meta:resourcekey=&quot;LabelTitleResource1&quot;<\/b>&gt;&lt;\/asp:Localize&gt;<\/p>\n<p><\/p>\n<p>The Text property of the Button control is to aid the developer at design time.<\/p>\n<p><a href=\"http:\/\/asp.net\/\">ASP.NET<\/a> will use the key to find and match on any property that might be set inside the resource file as meta:resourcekey.&lt;PropertyName&gt; or ButtonFindResoure1.Text:<\/p>\n<p>&lt;data name=&quot;ButtonFindResource1.Text&quot; xml:space=&quot;preserve&quot;&gt;<\/p>\n<p>\u00a0 \u00a0 \u00a0&lt;value&gt;Find&lt;\/value&gt;<\/p>\n<p>&lt;\/data&gt;<\/p>\n<p>&lt;data name=&quot;ButtonFindResource1.Tooltip&quot; xml:space=&quot;preserve&quot;&gt;<\/p>\n<p>\u00a0 \u00a0 \u00a0&lt;value&gt;Click this to start the search action&lt;\/value&gt;<\/p>\n<p>&lt;\/data&gt;<\/p>\n<p><\/p>\n<p>Accessing a Local resource in C# could be done as follows:<\/p>\n<p>Textbox1.Text = <b>GetLocalResourceObject<\/b>(&#8220;Textbox1.Text&#8221;).ToString();<\/p>\n<p><\/p>\n<p>Accessing a shared global resource in C# could be done in one of the two followings:<\/p>\n<p>Textbox1.Text = Resources.ResourceFileName.Textbox1Text;<\/p>\n<p>Textbox1.Text = <b>GetGlobalResourceObject<\/b>(&#8220;ResourceFileName&#8221;, &#8220;Textbox1Text&#8221;) as string;<\/p>\n<p> <\/p>\n<p>The methods GetGlobalResourceObject \u00a0and GetLocalResourceObject can come handy when the resources does not exist at compile time and might be provided as a separate dll at runtime.<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are two kind of localizations: Local resources are specific to a page. Global resources are shared throughout the site If your site contains many folders, you might have an App_LocalResources subfolder in each folder of your site. &lt;asp:Button ID=&quot;ButtonFind&quot; runat=&quot;server&quot; Text=&quot;Find&quot; CssClass=&quot;submitButton&quot; meta:resourcekey=&quot;ButtonFindResource1&quot; \/&gt; &lt;asp:Localize ID=&quot;LabelTitle&quot; runat=&quot;server&quot; Text=&quot;Customer Lookup&quot; meta:resourcekey=&quot;LabelTitleResource1&quot;&gt;&lt;\/asp:Localize&gt; The Text property of &hellip; <a href=\"http:\/\/panahy.nl\/index.php\/2011\/10\/14\/localizing-asp-net-tips\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Localizing ASP.NET Tips&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"post-thumbnail":false},"uagb_author_info":{"display_name":"Pouya Panahy","author_link":"http:\/\/panahy.nl\/index.php\/author\/pouya\/"},"uagb_comment_info":0,"uagb_excerpt":"There are two kind of localizations: Local resources are specific to a page. Global resources are shared throughout the site If your site contains many folders, you might have an App_LocalResources subfolder in each folder of your site. &lt;asp:Button ID=&quot;ButtonFind&quot; runat=&quot;server&quot; Text=&quot;Find&quot; CssClass=&quot;submitButton&quot; meta:resourcekey=&quot;ButtonFindResource1&quot; \/&gt; &lt;asp:Localize ID=&quot;LabelTitle&quot; runat=&quot;server&quot; Text=&quot;Customer Lookup&quot; meta:resourcekey=&quot;LabelTitleResource1&quot;&gt;&lt;\/asp:Localize&gt; The Text property of&hellip;","_links":{"self":[{"href":"http:\/\/panahy.nl\/index.php\/wp-json\/wp\/v2\/posts\/46"}],"collection":[{"href":"http:\/\/panahy.nl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/panahy.nl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/panahy.nl\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/panahy.nl\/index.php\/wp-json\/wp\/v2\/comments?post=46"}],"version-history":[{"count":0,"href":"http:\/\/panahy.nl\/index.php\/wp-json\/wp\/v2\/posts\/46\/revisions"}],"wp:attachment":[{"href":"http:\/\/panahy.nl\/index.php\/wp-json\/wp\/v2\/media?parent=46"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/panahy.nl\/index.php\/wp-json\/wp\/v2\/categories?post=46"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/panahy.nl\/index.php\/wp-json\/wp\/v2\/tags?post=46"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}