473,320 Members | 2,012 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Dropdownlist State??

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?
Nov 18 '05 #1
3 1083
Curt Emich wrote:
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.

--
W '04 <:> Open
Nov 18 '05 #2
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

"Curt Emich" <ce****@comcast.net> wrote in message
news:CN********************@comcast.com...
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?

Nov 18 '05 #3
"Curt Emich" <ce****@comcast.net> wrote in message news:<CN********************@comcast.com>...
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
Je**@Bennet-Tec.Com

* 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

=================== ===================
Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: rmorvay | last post by:
I am trying to dynamically build a dropdownlist and bind it to a cell in a grid. I tried to utilize the following code but I am stuck at the point where I bind the dropdownlist to the grid cell. ...
2
by: Leon Shaw | last post by:
have two Dropdownlist and one which is containing States and one containing Cities. I know how to do all the little databinding task in visual studios interface as well as set the relationship...
6
by: Robin Bonin | last post by:
In my user contol I am creating a set of dropdownlists. Each list is created based on input from the other lists. The problem I am having is setting the selected index on the lists. If someone...
1
by: Liz | last post by:
I have a page with several dropdownlists, several text boxes and several buttons which perform calculations. I need to validate one dropdownlist (not the whole page) with the click of one button. I...
0
by: JJ_377 | last post by:
The following doesn't assign value to the dropdownlist - WHY? ___________________________________________________________________ In a user control (ascx named USACustomer) : Public Property...
1
by: Frank | last post by:
Hello, I have some text boxes and 2 drop down lists (DDL) within a panel like so: Everything updates fine but the values from the DDLs are always the items selected by default. In other words,...
8
by: Rick | last post by:
I have been trying to get this dropdownlist to run and I am having nothing but errors. Anyone know what I am doing wrong? Any help would be much appreciated!!! Here is my code. <script...
0
by: Theam Kok Ming | last post by:
Hi All, I am a newbie to ASP.Net 2.0 . I would appreciate if anyone can enlighten me on my doubts I am building a simple customer registration website. I have the tables and GridView to...
1
by: 47computers | last post by:
Hello. I'm having a bit of difficulty with some DropDownList controls within templates in a DetailsView on my web form. Basically, I have a form where a user is building a "location profile" with...
0
by: 47computers | last post by:
Hello. I'm having a bit of difficulty with some DropDownList controls within templates in a DetailsView on my web form. Basically, I have a form where a user is building a "location profile" with...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.