<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Control.ascx.cs" Inherits="ChooseCultureControl" %>
<div id="cultureStyle">
<asp:Localize ID="locCountry" runat="server" meta:resourcekey="locCountry1" Text="Country :" ></asp:Localize>
<asp:ImageButton ID="imgUS" runat="server"
CssClass="cultureFlag" BorderWidth="1"
CommandName="US"
OnCommand="imgCommand"
ImageUrl="images/flag_us.gif"
meta:resourcekey="imgUSResource1" />
<asp:ImageButton ID="imgFR" runat="server"
CssClass="cultureFlag" BorderWidth="1"
CommandName="France"
OnCommand="imgCommand"
ImageUrl="images/flag_fr.gif"
meta:resourcekey="imgFRResource1" />
</div>
File: Control.ascx.cs
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class ChooseCultureControl : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
if (Profile.Culture == "fr-FR")
{
imgFR.BorderStyle = BorderStyle.Dotted;
imgUS.BorderStyle = BorderStyle.None;
}
else
{
imgUS.BorderStyle = BorderStyle.Dotted;
imgFR.BorderStyle = BorderStyle.None;
}
}
protected void imgCommand(object sender, CommandEventArgs e)
{
if (e.CommandName == "France")
Profile.Culture = "fr-FR";
else
Profile.Culture = "en-US";
Response.Redirect(Request.Url.AbsolutePath);
}
}
File: Web.config
<?xml version="1.0"?>
<configuration>
<system.web>
<anonymousIdentification enabled="true"/>
<profile>
<properties>
<add name="Culture" type="string" allowAnonymous="true" defaultValue="auto"/>
</properties>
</profile>
<compilation debug="true"/>
</system.web>
</configuration>
|