File ->New->WebSite
Add->Add New Item
And Click on Add Button
And Again New Item
And Again New Item
write the following Code
.
Write the following Code in Default.aspx
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="drpLanguage" runat="server" OnSelectedIndexChanged="drpLanguage_SelectedIndexChanged" AutoPostBack="true">
<asp:ListItem Value="0">Select</asp:ListItem>
<asp:ListItem Value="en-US">English</asp:ListItem>
<asp:ListItem Value="fr-CA">French</asp:ListItem>
</asp:DropDownList>
<asp:Label ID="lblText" runat="server" Text="<%$Resources:language, Name%>"></asp:Label>
</div>
</form>
Default.aspx.cs
.cs Code
protected void Page_Load(object sender, EventArgs e)
{
if (Session["language"] != null)
{
drpLanguage.SelectedValue = Convert.ToString(Session["language"]);
}
Session["language"] = null;
}
protected void drpLanguage_SelectedIndexChanged(object sender, EventArgs e)
{
if (drpLanguage.SelectedValue != "0")
{
Session["language"] = drpLanguage.SelectedValue;
string value = Convert.ToString(drpLanguage.SelectedValue);
Utility.DefaultLanguage = value;
drpLanguage.SelectedItem.Value = Utility.DefaultLanguage;
Server.Transfer(Request.Path);
}
else
{
Response.Write("<script>alert('Please select Language'); </script>");
lblText.Text = "";
}
}
In App_GlobalResources Folder, Right Click and Select Add
Add->New Item
Give the Name as Language.resx and enter the following Details.
Again Add New Item
Give the Name as Language.fr-CA.resx and enter the following Details.
Build the Solution and see the output.
Add->Add New Item
Add New WebForm
And Click on Add Button
And Again New Item
Write the following Code
And Again New Item
write the following Code
.
Write the following Code in Default.aspx
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="drpLanguage" runat="server" OnSelectedIndexChanged="drpLanguage_SelectedIndexChanged" AutoPostBack="true">
<asp:ListItem Value="0">Select</asp:ListItem>
<asp:ListItem Value="en-US">English</asp:ListItem>
<asp:ListItem Value="fr-CA">French</asp:ListItem>
</asp:DropDownList>
<asp:Label ID="lblText" runat="server" Text="<%$Resources:language, Name%>"></asp:Label>
</div>
</form>
Default.aspx.cs
.cs Code
protected void Page_Load(object sender, EventArgs e)
{
if (Session["language"] != null)
{
drpLanguage.SelectedValue = Convert.ToString(Session["language"]);
}
Session["language"] = null;
}
protected void drpLanguage_SelectedIndexChanged(object sender, EventArgs e)
{
if (drpLanguage.SelectedValue != "0")
{
Session["language"] = drpLanguage.SelectedValue;
string value = Convert.ToString(drpLanguage.SelectedValue);
Utility.DefaultLanguage = value;
drpLanguage.SelectedItem.Value = Utility.DefaultLanguage;
Server.Transfer(Request.Path);
}
else
{
Response.Write("<script>alert('Please select Language'); </script>");
lblText.Text = "";
}
}
In App_GlobalResources Folder, Right Click and Select Add
Add->New Item
Give the Name as Language.resx and enter the following Details.
Again Add New Item
Give the Name as Language.fr-CA.resx and enter the following Details.
Build the Solution and see the output.
No comments:
Post a Comment
Thank you for visiting my blog