Dropdownlist State??

C

Curt Emich

Is there a better way in .NET to preserve the state of say, a dropdown list
other than using hidden fields and the like? I've noticed that the method
"SelectedIndexChanged" of a dropdown list is only called when "Autopostback"
is true. This seems to defeat the purpose altogether.

When I change the value in a dropdown listbox, I want to know what the
ORIGINAL value was so that I can PRESERVE that value when the page is
re-rendered. As it stands, I don't see any method that is fired BEFORE
postback that would allow me to store the original value of the listbox.

Do I just go back to good old fashioned javascript?
 
G

Guy Blanc

Curt said:
Is there a better way in .NET to preserve the state of say, a dropdown
list
other than using hidden fields and the like? I've noticed that the
method "SelectedIndexChanged" of a dropdown list is only called when
"Autopostback"
is true. This seems to defeat the purpose altogether.

When I change the value in a dropdown listbox, I want to know what the
ORIGINAL value was so that I can PRESERVE that value when the page is
re-rendered. As it stands, I don't see any method that is fired BEFORE
postback that would allow me to store the original value of the listbox.

Do I just go back to good old fashioned javascript?

If the user is seeing the dropdown for the first time, then the value is the
default value. If this is a prepopulated form based on some choices the
user made earlier, well then the /original/ value would be stored in a
database or XML file or whatever you are using to store information.
 
T

Teemu Keiski

Hi,

SelectedIndexChanged event will raise even if the AutoPostBack wouldn't be
enabled. Only thing that could prevent it from working is that you'd for
example populate the DDL every time the Page loads (not for example only at
the initial request).

And you'd need to manually save the value on previous request for example to
ViewState (say at OnPreRender stage of Page), so that you could see at
postback what it was compared to the current value. DDL itself lets you only
to the currently selected value, so it doesn't relate to the
autopostbacking.

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
http://blogs.aspadvice.com/joteke



Is there a better way in .NET to preserve the state of say, a dropdown list
other than using hidden fields and the like? I've noticed that the method
"SelectedIndexChanged" of a dropdown list is only called when "Autopostback"
is true. This seems to defeat the purpose altogether.

When I change the value in a dropdown listbox, I want to know what the
ORIGINAL value was so that I can PRESERVE that value when the page is
re-rendered. As it stands, I don't see any method that is fired BEFORE
postback that would allow me to store the original value of the listbox.

Do I just go back to good old fashioned javascript?
 
J

Jeff Bennett

Curt Emich said:
Is there a better way in .NET to preserve the state of say, a dropdown list
other than using hidden fields and the like? I've noticed that the method
"SelectedIndexChanged" of a dropdown list is only called when "Autopostback"
is true. This seems to defeat the purpose altogether.

When I change the value in a dropdown listbox, I want to know what the
ORIGINAL value was so that I can PRESERVE that value when the page is
re-rendered. As it stands, I don't see any method that is fired BEFORE
postback that would allow me to store the original value of the listbox.

Do I just go back to good old fashioned javascript?

If you are thinking of returning to JavaScript
take a look at DecisionScript at www.VanguardSW.com
No more stateless worries - DecisionScript takes care of that for you.

=> Drop me a note by e-mail if this seems interesting to
you. Please include a copy of this message with your reply


-----

Jeff Bennett
(e-mail address removed)

* Bennet-Tec Information Systems, Inc
* 50 Jericho Tpk, Jericho, NY 11753
* Phone 516 997 5596, Fax - 5597
* RELIABLE Components Make You Look Sharp!
* TList/Pro * ALLText HT/Pro * MetaDraw *
* Custom Software Development Services Too.
* WWW.Bennet-Tec.Com

=================== ===================
 

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

Top