ASP.NET 2.0 Localisation problem Localizable attribute not working...

A

aidancasey

I have written a custom control called CheckboxDataList that derives
from the DataList webControl.

My control contains a public property called CheckedValues. The type of
this property is a generic <List> of strings


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace BFarm.WebControls
{
public class BfarmCheckboxDataList : DataList
{
public List<string> CheckedValues
{
//
//
}
}

My control is defined as follows on my webform

<%@ Register Assembly="ControlLibrary" Namespace="ControlLibrary"
TagPrefix="cc1" %>

<form id="form1" runat="server">
<cc1:CheckboxDataList ID="BfarmCheckboxDataList1"
runat="server" RepeatColumns="14"
RepeatDirection="Horizontal" RepeatLayout="Table">
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat='server' />
&nbsp;
<asp:Label ID="Label1" runat='server'
Visible="false"></asp:Label>
</ItemTemplate>
</cc1:BCheckboxDataList>
</form>

I am using the designed to generate the local resource files fro my web
form ( in design view navigate to Tools and click on Generate Local
Resources).

The IDE seems to think that the property of my control CheckedValues
should be localised and it adds the following code to my webform
CheckedValues="(Collection)"


<cc1:BfarmCheckboxDataList ID="CheckboxDataList1" runat="server"
RepeatColumns="14"
RepeatDirection="Horizontal" CheckedValues="(Collection)"
meta:resourcekey="BfarmCheckboxDataList1Resource2" ReadOnly="False">
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat='server'
meta:resourcekey="CheckBox1Resource2" />
&nbsp;
<asp:Label ID="Label1" runat='server' Visible="False"
meta:resourcekey="Label1Resource2"></asp:Label>
</ItemTemplate>
</cc1:CheckboxDataList>

How can I prevent the ide from generating this code and how can I tell
the IDE not to treat this property as something that should be
localised?

I have tried decorating the property with the following attribute
[Localizable(false)]
But it does nothing

Help !!!
 
G

Gawel

Just decorate your property with following attributes:

[DefaultValue((string)null),
PersistenceMode(PersistenceMode.InnerDefaultProperty)]

Yes I know it's strange but it works.

Pawel Pabich
 
Joined
Sep 19, 2007
Messages
1
Reaction score
0
Hi i have the same problem
but in my case there are too many properties for the control not only one.
so PersistenceMode.InnerDefaultProperty will not work since only one property for each control should be marked as InnerDefaultProperty.
so i marked all properties as InnerProperty not InnerDefaultProperty it works but a new problem appears, is that some not all properties were being displayed as XML tags inside my control HTML :s
here is the control's HTML before and ater generating localize file:
Before:
<cc2:EsGrid ID="grdTest" runat="server">
<Columns>
<asp:BoundField DataField="Position" HeaderText="Test1" />
<asp:BoundField DataField="Courses" HeaderText="Test2" />
</Columns>
</cc2:EsGrid>

After:
<cc2:EsGrid ID="grdTest" runat="server" meta:resourcekey="grdTestResource1">
<Columns>
<asp:BoundField DataField="Position" HeaderText="Test1" meta:resourcekey="BoundFieldResource1"/>
<asp:BoundField DataField="Courses" HeaderText="Test2" meta:resourcekey="BoundFieldResource2"/>
</Columns>
<ToolbarStyleFolder>
</ToolbarStyleFolder>
<StyleFolder>
</StyleFolder>
<Localization>
grid/localization</Localization>
<ToolbarImageBreak>
</ToolbarImageBreak>
<ToolbarImageAfter>
</ToolbarImageAfter>
<Language>
</Language>
<ToolbarImageBefore>
</ToolbarImageBefore>
</cc2:EsGrid>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top