0
|
1 using System;
|
|
2 using System.Web.UI;
|
|
3 using System.Web.UI.WebControls;
|
|
4
|
|
5 using PetShop.BusinessLogic;
|
|
6
|
|
7 namespace PetShop.Web
|
|
8 {
|
|
9 public partial class NavigationControl : UserControl
|
|
10 {
|
|
11 // Control layout property.
|
|
12 //
|
|
13 private string _controlStyle;
|
|
14 protected string ControlStyle
|
|
15 {
|
|
16 get { return _controlStyle; }
|
|
17 }
|
|
18
|
|
19 // Get properties based on control consumer.
|
|
20 //
|
|
21 protected void GetControlStyle()
|
|
22 {
|
|
23 if (Request.ServerVariables["SCRIPT_NAME"].ToLower().IndexOf("default.aspx") > 0)
|
|
24 _controlStyle = "navigationLinks";
|
|
25 else
|
|
26 _controlStyle = "mainNavigation";
|
|
27 }
|
|
28
|
|
29 protected void Page_Load(object sender, EventArgs e)
|
|
30 {
|
|
31 GetControlStyle();
|
|
32 BindCategories();
|
|
33
|
|
34 // Select current category.
|
|
35 //
|
|
36 string categoryId = Request.QueryString["categoryId"];
|
|
37
|
|
38 if (!string.IsNullOrEmpty(categoryId))
|
|
39 SelectCategory(categoryId);
|
|
40 }
|
|
41
|
|
42 // Select current category.
|
|
43 //
|
|
44 private void SelectCategory(string categoryId)
|
|
45 {
|
|
46 foreach (RepeaterItem item in repCategories.Items)
|
|
47 {
|
|
48 HiddenField hidCategoryId = (HiddenField)item.FindControl("hidCategoryId");
|
|
49
|
|
50 if (hidCategoryId.Value.ToLower() == categoryId.ToLower())
|
|
51 {
|
|
52 HyperLink lnkCategory = (HyperLink)item.FindControl("lnkCategory");
|
|
53
|
|
54 lnkCategory.ForeColor = System.Drawing.Color.FromArgb(199, 116, 3);
|
|
55
|
|
56 break;
|
|
57 }
|
|
58 }
|
|
59 }
|
|
60
|
|
61 // Bind categories.
|
|
62 //
|
|
63 private void BindCategories()
|
|
64 {
|
|
65 repCategories.DataSource = new ProductManager().GetCategoryList();
|
|
66 repCategories.DataBind();
|
|
67 }
|
|
68 }
|
|
69 } |