views:

385

answers:

2

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.

A: 

Yes! I had this happen to me, but just on user controls as well. Is this a normal problem then? I don't know how to resolve it though.

Out of interest, is there any alternative to using Tools -> Generate Local Resource from the menu for building resource files??? I generally already attach my meta:resourcekey tags onto my localizable content controls and don't want it to change it for anything else.

Reddog
+1  A: 

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.

Reddog