protected void CreateSubcategories() { Category currentCategory = CategoryService.GetCategoryById(CategoryId); //if current category doesn't have subcategories, hide the category filter if (CategoryService.GetAllCategoriesByParentCategoryId(CategoryId).Count == 0) { pnlSubCategories.Attributes.Add("style", "display: none"); return; } else { List<Category> subCategories = new List<Category>(); if (currentCategory != null) { subCategories = CategoryService.GetAllCategoriesByParentCategoryId(CategoryId); } //Render subcategories foreach (Category subCategory in subCategories) { NopcommerceLi li = new NopcommerceLi(); li.HyperLink.Attributes.Add("class", "unSelected"); li.HyperLink.Attributes.Add("onclick", "return AjaxClient.OnSubcategoryClick(this)"); li.HyperLink.Attributes.Add("href", "#" + subCategory.CategoryId); li.HyperLink.Text = Server.HtmlEncode(subCategory.LocalizedName); phCategories.Controls.Add(li); } } }
protected void CreateManufacturers() { int totalRecords; List<Product> ps = new List<Product>(); List<Manufacturer> ms = new List<Manufacturer>(); List<int> Ids = new List<int>(); if (CategoryService.GetCategoryById(CategoryId) != null) { foreach (int Id in getSubcategoryIds(this.CategoryId)) { ps.AddRange(ProductService.GetAllProducts(Id, 0, 0, 0, false, 0, 0, out totalRecords)); } ps.AddRange(ProductService.GetAllProducts(CategoryId, 0, 0, 0, false, 0, 0, out totalRecords)); foreach (Product p in ps) { foreach (ProductManufacturer pm in p.ProductManufacturers) { if (!ms.Contains(pm.Manufacturer)) { ms.Add(pm.Manufacturer); } } } if (ms.Count == 0) { pnlManufacturers.Attributes.Add("style", "display:none"); } else { foreach (Manufacturer m in ms) { NopcommerceLi li = new NopcommerceLi(); li.HyperLink.Attributes.Add("class", "unSelected"); li.HyperLink.Attributes.Add("onclick", "return AjaxClient.OnManufacturerClick(this)"); li.HyperLink.Attributes.Add("href", "#" + m.ManufacturerId); li.HyperLink.Text = Server.HtmlEncode(m.LocalizedName); phManufacturers.Controls.Add(li); } } return; } }
protected void CreateSubcategories() { if (categories.Count == 0) { pnlSubCategories.Attributes.Add("style", "display:none"); } else { foreach (Category c in categories) { NopcommerceLi li = new NopcommerceLi(); li.HyperLink.Attributes.Add("class", "unSelected"); li.HyperLink.Attributes.Add("onclick", "return AjaxClient.OnSubcategoryClick(this)"); li.HyperLink.Attributes.Add("href", "#" + c.CategoryId); li.HyperLink.Text = Server.HtmlEncode(c.LocalizedName); phCategories.Controls.Add(li); } } }
protected void CreateManufacturers() { if (manufacturers.Count == 0) { pnlManufacturers.Attributes.Add("style", "display:none"); } else { foreach (Manufacturer m in manufacturers) { NopcommerceLi li = new NopcommerceLi(); li.HyperLink.Attributes.Add("class", "unSelected"); li.HyperLink.Attributes.Add("onclick", "return AjaxClient.OnManufacturerClick(this)"); li.HyperLink.Attributes.Add("href", "#" + m.ManufacturerId); li.HyperLink.Text = Server.HtmlEncode(m.LocalizedName); phManufacturers.Controls.Add(li); } } }
public void DataBind() { if (dataSource != null) { foreach (DataRow dr in dataSource.Rows) { var link = new NopcommerceLi(); link.HyperLink.Text = dr["Name"].ToString(); link.HyperLink.Attributes.Add("href", "#" + dr["Name"].ToString()); link.HyperLink.Attributes.Add("class", "unSelected"); link.HyperLink.Attributes.Add("onclick", "return AjaxClient.OnAttrClick(this);"); this.placeHold.Controls.Add(link); } } }
protected void CreateSubcategories() { if (categories.Count == 0) { pnlSubCategories.Attributes.Add("style", "display:none"); } else { //如果要是从 列表导航跳转过来的(只有一个ID) string manuTransId = Request.QueryString["manufacturerTransId"]; foreach (Category c in categories) { bool choiceSign = false; NopcommerceLi li = new NopcommerceLi(); if (manuTransId != "" && manuTransId != null) { foreach (int motId in getCategoryByCatecoryId(int.Parse(manuTransId))) { //如果要是有相等的话就 打钩 if (c.CategoryId == motId) { li.HyperLink.Attributes.Add("class", "selected"); li.HyperLink.Attributes.Add("onclick", "return AjaxClient.OnSubcategoryClick(this)"); li.HyperLink.Attributes.Add("href", "#" + c.CategoryId); li.HyperLink.Text = Server.HtmlEncode(c.LocalizedName); choiceSign = true; break; } } } if (choiceSign == false) { li.HyperLink.Attributes.Add("class", "unSelected"); li.HyperLink.Attributes.Add("onclick", "return AjaxClient.OnSubcategoryClick(this)"); li.HyperLink.Attributes.Add("href", "#" + c.CategoryId); li.HyperLink.Text = Server.HtmlEncode(c.LocalizedName); } phCategories.Controls.Add(li); } } }