I'm following up on a previous post but targeting in where I now think the problem lies. Here's my situation:
I have an ASP.Net 3.5 web project written in C#. I am trying to introduce a toolbar which is implemented as follows:
- Custom built toolbar, which consists of link buttons. It resides in a User Control.
- The User Control is instantiated at the top of a Master Page.
- The Master Page is referenced by several Content Pages.
I've constructed things in such a way that I can customize the names & images of each toolbar button. So, for example, one Content Page may display these toolbar buttons: Add Edit Move Save. While another Content Page may display these toolbar buttons: Insert Delete Save. Any combination of the known button types is permissible.
As you're probably envisioning, the toolbar buttons are instantiated dynamically, depending on what parameters are passed to the 'CreateCommandButtons' method within the User Control.
Everything is working fine except for one crucial thing: When I change the enabled/disabled setting of each toolbar button, the value is not remembered after a postback; in my particular case, it's a partial postback on an AJAX enabled page.
So I went back to basics and decided to simulate the same approach in a small test project, which you can download here: http://mwtech.com/downloads/public/Dynamic_Button_Creator.zip
Here's what you need to do:
- Run the WebForm1.aspx page in this project.
- Press the "Press Me to Alter Toolbar Buttons" button a few times. It causes a postback and increments the numeric value of each of the 3 toolbar link buttons.
- Now press "Enable Center Button". Notice how the center toolbar button turns blue, to denote it's enabled.
- Now press the same button as in Step #2 again. Postbacks continue to occur and yet the center button stays blue (ie. enabled).
So to my great surprise, the test project works fine!! Yet very similar code within my actual project is not working. Instead, there, when you execute Step #4 above, the center button would revert back to gray.
So I did more reading and it seems that it's the IPostBackDataHandler interface that is responsible for restoring the altered control values. Yet it's not doing this in my real project I'm hoping that someone familiar with IPostBackDataHandler can tell me what key things to look for to see why it's not functioning properly.
Robert