Last post Apr 23, 2011 06:29 AM by Dave Sussman
Apr 20, 2011 10:42 PM|jbackroads|LINK
I am building a web application using ASP.NET 4.0; this web site/application needs to be localized to display in multiple languages. At this point, I am using Global resource files for two reasons …
First, many strings (not all, but 80-90% or so) are used across more than one page and will be used in reports.
Second, I love the “strongly-typed” benefit of the global resources which makes it so much easier to code. But, I believe the strongly-typed feature only applies in the code behind, not in the ASP markup.
Question: Does populating the string values for a page in the code-behind file (using the Page_Load event) cause a significant performance (speed) hit compared to populating the string values through the ASP markup?
I’m just starting with this; I have localized one page using code-behind to populate the page’s string values in the Page_Load event with multiple lines like so:
lblPrintInvoice.Text = Resources.Base.Print__Invoices.ToString
This is working fine, I just want to make sure this is the best approach and doesn’t cause a noticeable performance hit compared to the alternative method of populating strings from the ASP markup.
Thanks for any input you can provide!
Apr 21, 2011 04:29 AM|Dave Sussman|LINK
This is probably what ASP.NET does underneath; or something similar at least. When it loads the page it has to iterate the controls and load the resource strings, so the perf difference is probably not going to be noticable. But I'd check to be sure; create
a test page and try it out.
Apr 22, 2011 12:40 AM|jbackroads|LINK
Hi Dave -
Thanks very much for the response!
When you say "this is probably what ASP.NET does underneath", I assume you mean server-side?
I have tried a couple of pages using both approaches and I can't tell a difference, but they're pretty simple pages. I figured I'd put the question out there and if there was an obvious performance difference known in the development community, people would
jump in and say so.
I plan to move forward with the strongly-typed, code-behind approach ... if I run into anything I'll post back here for future reference.
Apr 23, 2011 06:29 AM|Dave Sussman|LINK
Yes, server-side, as it builds the page.