Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 74701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:23:58+00:00 2026-05-10T20:23:58+00:00

I have a (derived) Menu control, that displays a rather large list of items

  • 0

I have a (derived) Menu control, that displays a rather large list of items from a custom data source. I need to disable ViewState on the menu to avoid the very annoying ‘Can’t select a disabled or unselectable menu item’ when some other control causes the current selection to change on a postback.

Unfortunately, when ViewState is disabled for the Menu, the postbacks generated by the menu aren’t raising any events. If I enable ViewState, the OnMenuItemClick event is raised. If I disable ViewState, OnMenuItemClick is not raised. I’m perplexed.

I need to leave ViewState off for the menu, so how can I handle postbacks from the actual menu?

At this point I’m leaning towards using the Menu’s Load event, parsing the __EVENTTARGET to see if it’s the Menu, and going from there. This would technically process the postback event before it would normally but that’s ok, I guess.

Any better ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T20:23:59+00:00Added an answer on May 10, 2026 at 8:23 pm

    I’ve figured out the essence of the problem. Using Reflector we can see the important part(s) of the low level method that handles the actual postback and then raises the event:

    string str = HttpUtility.HtmlDecode(eventArgument); ... MenuItem item = this.Items.FindItem(str.Split(new char[] { '\\' }), 0); if (item != null)     this.OnMenuItemClick(new MenuEventArgs(item)); 

    As you can see the MenuEventArgs is handed a MenuItem. If one cannot be found in the current Items collection that matches the incoming post data, then the event is not raised. With ViewState disabled, the menu doesn’t have any Items (they would have been rebuilt using ViewState). So the event won’t be raised.

    To work around this, I’ve told the menu to build itself during Load using the not-yet-updated data (at this point it will be the same as it was at the end of the last request). This is essentially the same as rebuilding the menu from ViewState, so I don’t feel bad in regards to performance, or whatever. OnMenuItemClick is then fired as expected. Lastly, during PreRender I tell the Menu to rebuild once again, so it reflects the changes that happened during the postback processing portion of the lifecycle.

    I wasted a lot of time on this, so hopefully this info can help somebody else in a similar situation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 65k
  • Answers 65k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Option 1 will be slower than Option 2. Lambda expressions… May 11, 2026 at 11:13 am
  • added an answer You asked for a practical example of volatile member functions.… May 11, 2026 at 11:13 am
  • added an answer Ian's solution seems like a pretty good long term solution,… May 11, 2026 at 11:13 am

Related Questions

I have a (derived) Menu control, that displays a rather large list of items
I have a base class which is non-generic with a derived generic class. The
Suppose I have a base class B, and a derived class D. I wish
I have a window (derived from JFrame) and I want to disable the close
I have derived a TabControl with the express purpose of enabling double buffering, except
I have a calendar control derived from DataGridView. A custom item hover event is
I have a generic class in my project with derived classes. public class GenericClass<T>
Let's say I have a Base class and several Derived classes. Is there any
I have written a new custom component derived from TLabel. The component adds some
I have a BasePage class which all other pages derive from: public class BasePage

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.