Reputation: 3
I have a page with few images. Also have a page where content based on drop down link is pulled from db. I currently have this code for !ispostback
private void FillPage()
{
ArrayList categoryList = new ArrayList();
if (!IsPostBack)
{
categoryList = ConnectionClass.GetMenuByCategory("Appetizer");
}
else
{
categoryList = ConnectionClass.GetMenuByCategory(DropDownList1.SelectedValue);
}
is is possible based on what img is clicked to change the inital getmenubycategory from appetizer to what ever img is selected. Thanks
Upvotes: 0
Views: 171
Reputation: 34846
Try this:
private void FillPage()
{
ArrayList categoryList = new ArrayList();
if (!IsPostBack)
{
if (Request.QueryString["category"] != null)
{
string categoryName = Request.QueryString["category"] as string;
if(!String.IsNullOrEmpty(categoryName)
{
switch(categoryName)
{
case "Entree":
categoryList = ConnectionClass.GetMenuByCategory("Entree");
break;
case "Dessert":
categoryList = ConnectionClass.GetMenuByCategory("Dessert");
break;
default:
categoryList = ConnectionClass.GetMenuByCategory("Appetizer");
break;
}
}
}
}
else
{
categoryList = ConnectionClass.GetMenuByCategory(DropDownList1.SelectedValue);
}
Upvotes: 1
Reputation: 14253
You can use GET method:
<a href="go.aspx?img=1"><img src="img1.jpg/></a>
<a href="go.aspx?img=2"><img src="img2.jpg/></a>
and in code behind:
if(!String.IsNullOrEmpty(Request.QueryString["img"]))
if(Request.QueryString["img"]=="1")
//some initializing
else
//another initializing
Upvotes: 0