localization in a web form


Author
Message
Eric Leissler
Eric Leissler
StrataFrame User (185 reputation)StrataFrame User (185 reputation)StrataFrame User (185 reputation)StrataFrame User (185 reputation)StrataFrame User (185 reputation)StrataFrame User (185 reputation)StrataFrame User (185 reputation)StrataFrame User (185 reputation)StrataFrame User (185 reputation)
Group: StrataFrame Users
Posts: 0, Visits: 527
Hi,

Well, i have a web form and on this web from i have two  imagebutton

one with french flac on the second with UK flag

i have this code  on click event

Protected Sub ImageButton2_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton2.Click

If MicroFour.StrataFrame.UI.Localization.MessageLocaleID = 1036 Then

MicroFour.StrataFrame.UI.Localization.MessageLocaleID = 1033

End If

End Sub

Protected Sub ImageButton1_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click

If MicroFour.StrataFrame.UI.Localization.MessageLocaleID = 1033 Then

MicroFour.StrataFrame.UI.Localization.MessageLocaleID = 1036

End If

End Sub

when i running this web site, i have to click   first, and i have to click a second time on the same immagebutton. After the second click,  the localization is made.

Look its not a double click but on click and after on click.

If i juste made on click, the localization does'nt running

What's the mater.??

What il forgget ?? 

Thanks 

Best regard

Eric

Reply
Mike Carter
Mike Carter
StrataFrame Team Member (4 reputation)StrataFrame Team Member (4 reputation)StrataFrame Team Member (4 reputation)StrataFrame Team Member (4 reputation)StrataFrame Team Member (4 reputation)StrataFrame Team Member (4 reputation)StrataFrame Team Member (4 reputation)StrataFrame Team Member (4 reputation)StrataFrame Team Member (4 reputation)
Group: Forum Members
Posts: 2, Visits: 15
Hi Eric,

We are working on enhancing some of the StrataFrame functionality for the web (new features and framework enhancements). 

The issue you are facing is a result of when StrataFrame is populating the controls with localized strings (Page_Load).

There are a couple of things you can do to work-around this problem for now:

1) call this static method on all your localized controls after setting Localization.MessageLocaleID = ####; (in my case, a Label named lblHello):

Localization.SetLocalizationOnControl(lblHello);

2) To solve this more generically, in your page implement the Page_PreRender method and call a method in your ApplicationBasePage.cs to loop through all controls, and for ones that implement ILocalizable call the SetLocalizationOnControl(control) as done above

 

Example ApplicationBasePage.cs:

using MicroFour.StrataFrame.Tools;

using System.Web.Configuration;

using System.Web.UI;

using MicroFour.StrataFrame.UI;

public class ApplicationBasePage : MicroFour.StrataFrame.UI.Web.BasePage, ITypeResolver

{

protected void LocalizeControls(Control root)

{

foreach (Control control in root.Controls)

{

if (control.Controls.Count > 0)

{

LocalizeControls(control);

}

if (control is ILocalizable)

{

Localization.SetLocalizationOnControl((ILocalizable)control);

}

}

}

protected void LocalizeControls()

{

LocalizeControls(Page);

}

}

Does that help?  I can send you a working sample, if that helps.


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search