Mercurial > pub > bltoolkit
diff Demo/Asp.Net/Web/Controls/NavigationControl.ascx.cs @ 0:f990fcb411a9
Копия текущей версии из github
author | cin |
---|---|
date | Thu, 27 Mar 2014 21:46:09 +0400 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Demo/Asp.Net/Web/Controls/NavigationControl.ascx.cs Thu Mar 27 21:46:09 2014 +0400 @@ -0,0 +1,69 @@ +using System; +using System.Web.UI; +using System.Web.UI.WebControls; + +using PetShop.BusinessLogic; + +namespace PetShop.Web +{ + public partial class NavigationControl : UserControl + { + // Control layout property. + // + private string _controlStyle; + protected string ControlStyle + { + get { return _controlStyle; } + } + + // Get properties based on control consumer. + // + protected void GetControlStyle() + { + if (Request.ServerVariables["SCRIPT_NAME"].ToLower().IndexOf("default.aspx") > 0) + _controlStyle = "navigationLinks"; + else + _controlStyle = "mainNavigation"; + } + + protected void Page_Load(object sender, EventArgs e) + { + GetControlStyle(); + BindCategories(); + + // Select current category. + // + string categoryId = Request.QueryString["categoryId"]; + + if (!string.IsNullOrEmpty(categoryId)) + SelectCategory(categoryId); + } + + // Select current category. + // + private void SelectCategory(string categoryId) + { + foreach (RepeaterItem item in repCategories.Items) + { + HiddenField hidCategoryId = (HiddenField)item.FindControl("hidCategoryId"); + + if (hidCategoryId.Value.ToLower() == categoryId.ToLower()) + { + HyperLink lnkCategory = (HyperLink)item.FindControl("lnkCategory"); + + lnkCategory.ForeColor = System.Drawing.Color.FromArgb(199, 116, 3); + + break; + } + } + } + + // Bind categories. + // + private void BindCategories() + { + repCategories.DataSource = new ProductManager().GetCategoryList(); + repCategories.DataBind(); + } + } +} \ No newline at end of file