When I localize an asp.net page that is using bound controls (DetailsView, etc) that has TemplateFields bound using the <%# Bind() #> syntax, after the localization all of the bindings are removed and I have to go back in & rebind everything. I’m creating the localized resource file by switching to design view, then Tools / Generate Local Resource from the menu.
Has anyone else seen this problem, and if so, do you have any suggestions for a workaround?
Before:
<asp:TemplateField HeaderText='First Name:'> <InsertItemTemplate> <uc:FirstNameTextBox runat='server' ID='FirstName' ValidationGroup='Main' Text='<%# Bind('FirstName') %>' /> </InsertItemTemplate> </asp:TemplateField>
After:
<asp:TemplateField HeaderText='First Name:' meta:resourcekey='TemplateFieldResource1'> <InsertItemTemplate> <uc:FirstNameTextBox runat='server' ID='FirstName' ValidationGroup='Main' /> </InsertItemTemplate> </asp:TemplateField>
Edit: Looks like its just my own UserControls that lose the binding. I tried adding the Bindable and Localizable(false) attributes to the properties, but that didn’t seem to help.
Just found this… http://blog.smart-ms.ordina.nl/Generate+Local+Resource+Files.aspx
Seems to do the trick without mangling your ASPX file at all… I’ve not run it over a master page / user control yet.