User1007520750 posted
Hi
This can be done by using a creating a usercontrol for the matter, and sending the culture info with it. I've created the following page and UserControl.
ASPX page:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" UICulture="auto" %>
<%@ Register src="CalendarUC.ascx" tagname="CalendarUC1" tagprefix="uc1" %>
<%@ Register src="CalendarUC.ascx" tagname="CalendarUC2" tagprefix="uc2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<uc1:CalendarUC1 ID="CalendarUC1" runat="server" culture="en-US" />
<uc2:CalendarUC2 ID="CalendarUC2" runat="server" culture="ar-SA" />
</div>
</form>
</body>
</html>
CalendarUC.ascx
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="CalendarUC.ascx.cs"
Inherits="WebApplication1.CalendarUC" %>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Calendar ID="Calendar1" runat="server"></asp:Calendar>
</ContentTemplate>
</asp:UpdatePanel>
CalendarUC.ascx.cs
using System;
using System.Globalization;
using System.Threading;
public partial class CalendarUC : System.Web.UI.UserControl
{
private string localCulture;
public string culture
{
get { return localCulture; }
set { localCulture = value; }
}
protected void Page_Load(object sender, EventArgs e)
{
Thread.CurrentThread.CurrentUICulture = new CultureInfo(culture);
}
}
This is still not in place because the result is two calendars with the last culture set. I've tried to follow
this instruction, and add an override to the 'FrameworkInitialize' in the CultureUC codebehined:
protected override void FrameworkInitialize()
{
Thread.CurrentThread.CurrentUICulture = new CultureInfo(culture);
}
But here the problem is that this is evaluated long before the property is sat, so the culture property is null at that point.
Anyone has a suggestion?
Amit