如何在下拉语言更改时更改网站面包屑? [英] How to change website breadcrumbs on drop down language change?
本文介绍了如何在下拉语言更改时更改网站面包屑?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的网站上,我使用的是语言下拉列表.
在下拉列表项更改上,我希望所有面包屑都更改.
我正在为此目的使用一个函数.
但是,它似乎不起作用,语言仍然是默认语言,即;英语.
该函数是:
Hi,
In my site i am using a language drop down list.
On drop down list item change i want all the breadcrumbs to change.
I am using a function for this purpose.
However, it doesn''t seem to work and language remains the default, i.e; English.
The function is:
#region SiteMap Functions
private SiteMapNode ExpandForumPaths(Object sender, SiteMapResolveEventArgs e)
{
try
{
if (SiteMap.CurrentNode != null)
{
SiteMapNode currentNode = SiteMap.CurrentNode.Clone(true);
SiteMapNode tempNode = currentNode;
if (tempNode.Title.ToString().ToLower().Contains("view") && !tempNode.Title.ToString().ToLower().Equals("event view"))
{
string[] url = HttpContext.Current.Request.Url.AbsoluteUri.ToString().Split(''?'');
url = url[1].Split(''='');
clsPage objPage = new clsPage();
DataTable dtPage = objPage.dtSelectPageUsingID(Convert.ToInt32(url[1].ToString()));
if (dtPage.Rows.Count > 0)
{
tempNode.Title = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(dtPage.Rows[0]["PageName"].ToString().ToLower());
if (!dtPage.Rows[0]["ParentPageID"].ToString().Equals("0"))
{
if (dtPage.Rows[0]["ParentPageName"].ToString() == "ABOUT US")
{
tempNode.ParentNode.Url = "../Public/Aboutus.aspx";// +"?PageID=" + dtPage.Rows[0]["ParentPageID"].ToString();
if (DropDownList1.Text == "English")
{
tempNode.ParentNode.Title = dtPage.Rows[0]["ParentPageName"].ToString();
}
else
{
tempNode.ParentNode.Title = GetLanguageHeaders(1);
}
}
else if (dtPage.Rows[0]["ParentPageName"].ToString() == "LOCATIONS")
{
tempNode.ParentNode.Url = "../Public/locations_map.aspx";// +"?PageID=" + dtPage.Rows[0]["ParentPageID"].ToString();
if (Session["LanguageID"] == null || Session["LanguageID"].ToString() == "1")
{
tempNode.ParentNode.Title = dtPage.Rows[0]["ParentPageName"].ToString();
}
else
{
tempNode.ParentNode.Title = GetLanguageHeaders(2);
}
}
else if (dtPage.Rows[0]["ParentPageName"].ToString() == "CASE STUDIES")
{
tempNode.ParentNode.Url = "../Public/casestudies.aspx";// +"?PageID=" + dtPage.Rows[0]["ParentPageID"].ToString();
if (Session["LanguageID"] == null || Session["LanguageID"].ToString() == "1")
{
tempNode.ParentNode.Title = dtPage.Rows[0]["ParentPageName"].ToString();
}
else
{
tempNode.ParentNode.Title = GetLanguageHeaders(3);
}
}
else if (dtPage.Rows[0]["ParentPageName"].ToString() == "NEWS")
{
tempNode.ParentNode.Url = "../Public/news.aspx";// +"?PageID=" + dtPage.Rows[0]["ParentPageID"].ToString();
if (Session["LanguageID"] == null || Session["LanguageID"].ToString() == "1")
{
tempNode.ParentNode.Title = dtPage.Rows[0]["ParentPageName"].ToString();
}
else
{
tempNode.ParentNode.Title = GetLanguageHeaders(4);
}
}
}
}
}
else if (tempNode.ParentNode != null)
{
if (tempNode.ParentNode.Title.ToString().ToLower().Contains("view") && !tempNode.Title.ToString().ToLower().Equals("event view"))
{
clsPage objPage = new clsPage();
if (tempNode.Title.ToLower().Equals("event calender"))
{
tempNode.ParentNode.Url = tempNode.ParentNode.Url + "?PageID=" + (int)ParentPageID1.NEWS;
tempNode.ParentNode.Title = "NEWS";
}
}
}
return currentNode;
}
}
catch (Exception ex)
{
throw ex;
}
return SiteMap.CurrentNode;
}
#endregion
在Page load evnet中称为它.
It is called in the Page load evnet.
#region Object Decleration And Page Load Function
clsHeaderImages objHeaderImages = null;
protected void Page_Load(object sender, EventArgs e)
{
if (DropDownList1.Items.Count > 0)
{
Session["LanguageID"] = DropDownList1.SelectedValue;
}
DropDownList1.DataSource = SqlDataSource1;
DropDownList1.DataTextField = "LangName";
DropDownList1.DataValueField = "LangID";
DropDownList1.DataBind();
if (Session["LanguageID"] != null)
{
DropDownList1.SelectedValue = Session["LanguageID"].ToString();
GetLanguageHeaders();
}
if (Session["Role"] != null)
{
if (Session["Role"].ToString().ToLower() == "admin")
Edit.Visible = true;
else
Edit.Visible = false;
}
else
Edit.Visible = false;
SiteMap.Providers["A"].SiteMapResolve +=
new SiteMapResolveEventHandler(this.ExpandForumPaths);
title.Text = "Corporate travel management | GSM | Global coverage local expertise";
description.Content = "GSM Specialist travel management offering service excellence and strategic solutions. Uniquely personal proposition for corporate travel. global coverage local expertise";
if (Session["UserName"] == null)
{
PartnerLogin.Visible = true;
PartnerHome.Visible = false;
}
else
{
PartnerHome.Visible = true;
PartnerLogin.Visible = false;
}
TranslateLanguage();
//TranslateLanguage();
LoadHeaderImages();
}
#endregion
请在我缺少逻辑的地方帮我!!!
Kindly help me where i am missing the logic!!!
推荐答案
您正在尝试在其中查找值之后绑定语言下拉列表的数据.在Page_Load的第1行上插入一个中断,然后查看DropDownList1(重命名)是否有任何项.我想不会.
You''re data binding the language dropdown after you try to look up a value in it. Put a break in there on line 1 of Page_Load and see if DropDownList1 (rename that, by the way) has any items. I guess it won''t.
这篇关于如何在下拉语言更改时更改网站面包屑?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文