Menu User Control & Postback

M

MikeB

Hello All, I have UserControl that consists of a Menu control. When a user
selects an item in the Menu I set a Public variable in the MenuItemClick
event. My problem is that when the main webpage posts back, the
MenuItemClick isn't fired off until after the postback so I can not get it
and my SelectedCategoryID is always 0. Can anyone tell me what I am doing
wrong? Below are snippets of my code:

MENU.ascx

private int _CategoryID = 0;

protected void Menu1_MenuItemClick(object sender, MenuEventArgs e)
{
_CategoryID = Convert.ToInt32(e.Item.Value);
}

public int SelectedCategoryID
{
get
{
return _CategoryID;
}
}


Then in my webpage, I have something that checks for the Menu
if (Menus1.SelectedCategoryID != 0)
{}
else
{}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,058
Latest member
QQXCharlot

Latest Threads

Top