http://example.com/UI/ProductUI.aspx/GetProductByCategory/1
Regarding the url, I want to pass the url value 1 in my content page method parameter when click in left navigation. The left navigation item is my Category Item and I load it from my category table in my master page by looping. Now I need the item value field e.g categoryId pass my content page method perimeter when click this item.
My Master page code is below:
<div class="left">
<%
CategoryManager aCategoryManager=new CategoryManager();
List<Category> categories = aCategoryManager.GetCategories();
foreach (Category category in categories)
{%>
<ul>
<li><a href="/UI/ProductUI.aspx/GetProductByCategory/<%: category.CategoryId %>"><%: category.CategoryName%></a></li>
</ul>
<% }%>
</div>
and my content page code is below:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
int id = Convert.ToInt32(Request.QueryString["CategoryId"]);
GetProductByCategory(id);
}
}
ProductManager aProductManager=new ProductManager();
private void GetProductByCategory(int categoryId)
{
List<Product> products = aProductManager.GetProductByCategory(categoryId);
GridView1.DataSource = products;
GridView1.DataBind();
}