Last post Mar 14, 2011 06:01 PM by e_man_online
Mar 11, 2011 12:03 PM|e_man_online|LINK
In ASP .NET 2.0, I've created a user control which is meant to work as a dropdown or popup by using an
<input type="button" id="btnTogglePopup" runat="server" style="display:inline"... /> and a
<div id="divPopup" runat="server" style="display:none" ... />
the rest of the controls are contained inside this div, and they do mantain their values between posts, etc.
The problem I'm having is that when a page containing this control posts back, the state visible/hidden of the div is not maintained. If the user had the popup open, after the postback, it will display closed.
I've read a bunch by now about ViewState & ControlState, and have the save and load contol state methods working, but when I step thru them they load old values (setting the popup to hidden all the time), and the popup doesn't work! I've come to think that
b/c when the button is clicked, the visible state of the div is changed in client code w/o a postback, maybe I have to maintain this state info in a hidden field or something like that??? At the same time I don't want to have a hidden field if it's unnecessary,
and I may just doing something wrong. Any help will be greatly appreciated.
Thanks in advance,
Mar 11, 2011 12:48 PM|Pankaj.Sharma|LINK
I could deduce as following by what you described
I could help you more precisly once i get the original purpose of the control
Mar 14, 2011 06:01 PM|e_man_online|LINK
The button hides/shows the div like a popup/dropdown.
The div contains a small gridview.
When I test the control on a page, I have a submit button, and a dropdown that posts back when selection changes.
I also placed several instances of my control on the page.
One instance has initial display mode "expanded" another "collapsed" etc.
When the page runs, if user changes the display mode of the instances of the controls, for example, collapse the one that was expanded, everything works fine.
But if the user clicks on the submit button or changes the selection in the dropdown, which also creates a post back, when the page is repainted, the display mode of the controls is lost, and returns to the original setting.
Please let me know whether it's clear now
Thanks in advance