473,734 Members | 2,798 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with Dropdown - ViewState and AutoPostBack

I have a page that works fine. I am trying to optimize the page by
overriding some of the Information that is being saved in the hidden
VIEWSTATE.

If I make the properties of the dropdown False for ViewState and True for
AutoPostBack, it does reload the page but does not call the
SelectedIndexCh anged event. If I put the ViewState to True then it is
called.

Does this mean that I cannot get that event and deal with it in better code
than what is required by using both the ViewState and AutoPostBack to true.
I want to cache some info so that is retrieved only when necessary not on
every page load.

Nov 17 '05 #1
3 3060
More info. A small project with a button and a listbox (ViewState =
"False") causes the following. If I click the listbox to change the
selection nothing happens. If I then click the button first the
ListBoxSelectio n Change happens then the Button Click.

Does this mean that the only way to get the listbox to send events (when
they happen) is to have the view state enabled??

If so I can only see this as a problem if you are trying to optimize the
code for page loads.
"Lloyd Sheen" <sq************ *******@tostops pamhotmail.com> wrote in message
news:ha******** *************@n ews04.bloor.is. net.cable.roger s.com...
I have a page that works fine. I am trying to optimize the page by
overriding some of the Information that is being saved in the hidden
VIEWSTATE.

If I make the properties of the dropdown False for ViewState and True for
AutoPostBack, it does reload the page but does not call the
SelectedIndexCh anged event. If I put the ViewState to True then it is
called.

Does this mean that I cannot get that event and deal with it in better code than what is required by using both the ViewState and AutoPostBack to true. I want to cache some info so that is retrieved only when necessary not on
every page load.

Nov 17 '05 #2
By default, the autopostback property of non-button type controls is set to
false. Without a post back your selection change event will not fire until
the next post back. When a form is posted back, all pending events are
processed. This is why the selection change happens as well as the button
click when you click it. To make the page process the selection change box
immediately, you need to set the autopostback property of the listbox to
true. This is completely unrelated to the viewstate.

I was minding my own business when Lloyd Sheen blurted out:
More info. A small project with a button and a listbox (ViewState =
"False") causes the following. If I click the listbox to change the
selection nothing happens. If I then click the button first the
ListBoxSelectio n Change happens then the Button Click.

Does this mean that the only way to get the listbox to send events (when
they happen) is to have the view state enabled??

If so I can only see this as a problem if you are trying to optimize the
code for page loads.
"Lloyd Sheen" <sq************ *******@tostops pamhotmail.com> wrote in message news:ha******** *************@n ews04.bloor.is. net.cable.roger s.com...
I have a page that works fine. I am trying to optimize the page by
overriding some of the Information that is being saved in the hidden
VIEWSTATE.

If I make the properties of the dropdown False for ViewState and True for
AutoPostBack, it does reload the page but does not call the
SelectedIndexCh anged event. If I put the ViewState to True then it is
called.

Does this mean that I cannot get that event and deal with it in better code than what is required by using both the ViewState and AutoPostBack to true. I want to cache some info so that is retrieved only when necessary not on
every page load.


--
Insert corny line here
Nov 17 '05 #3
JD
With the listbox, the items are saved in the viewstate. So the first time
your page is rendered you add the items to the listbox and everything is
fine. When a postback happens Load View State takes place, which repopulates
the listbox with the items that the listbox originally contained. Then after
this Load Postback Data happens which applies the user's selection to the
list box. If a selection took place, then the event will be fired latter on
in the page processing.

When you don't have viewstate enabled, on Load View State nothing in the
ListBox is repopulated, and when Load Postback Data happens the user
selection comes in but there are no items in the Listbox to apply the user
selection to, hence no event. If you don't want to use viewstate, you have
to repopulate the listbox yourself before Load Postback Data happens.
Essentailly you are taking over the view states responsibility but the data
is coming from server side cache, database, file, etc...
"Lloyd Sheen" <sq************ *******@tostops pamhotmail.com> wrote in message
news:OG******** *******@news01. bloor.is.net.ca ble.rogers.com. ..
More info. A small project with a button and a listbox (ViewState =
"False") causes the following. If I click the listbox to change the
selection nothing happens. If I then click the button first the
ListBoxSelectio n Change happens then the Button Click.

Does this mean that the only way to get the listbox to send events (when
they happen) is to have the view state enabled??

If so I can only see this as a problem if you are trying to optimize the
code for page loads.
"Lloyd Sheen" <sq************ *******@tostops pamhotmail.com> wrote in message news:ha******** *************@n ews04.bloor.is. net.cable.roger s.com...
I have a page that works fine. I am trying to optimize the page by
overriding some of the Information that is being saved in the hidden
VIEWSTATE.

If I make the properties of the dropdown False for ViewState and True for AutoPostBack, it does reload the page but does not call the
SelectedIndexCh anged event. If I put the ViewState to True then it is
called.

Does this mean that I cannot get that event and deal with it in better

code
than what is required by using both the ViewState and AutoPostBack to

true.
I want to cache some info so that is retrieved only when necessary not on every page load.


Nov 17 '05 #4

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

Similar topics

0
1380
by: Manish | last post by:
Hi All, I'm having this problem I hope someone can help provide a solution for it :) I've this dropdown list box in a usercontrol which I'm populating from the database (it's viewstate property is true).. when the user selects one of the items in the dropdown called "New Label" a popup window comes up where the user can add a new label once he adds a new label it is saved to the table and an event is fired from the Popup
2
3250
by: hypomite | last post by:
I have an handler for the SelectedIndexChanged event of a dropdown box. I have also set the AutoPostBack option to True. When you select any item besides the first one, the event sucessfully fires. However, if you ever (even after you have selected other options previously) select the first option in the dropdown, the AutoPostBack fires(the page reloads), but the event does not. This is the only element on my page and ViewState is enabled...
6
10687
by: Mark | last post by:
I have two dropdown lists. Both have autopostback set to true. In both dropdowns, when you select an item from the list, it redirects to the Value property of the dropdown. Nothing fancy. Let's say you select 1 of the items, and are properly redirected. You press the back button. I have three servers providing two different functionalities: 1. After pressing the back button, the item you selected in the dropdown is still selected.
2
4552
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was set to...it is set to false. Can someone show me what I am doing wrong and tell me the correct way? Thank you. In the page load event, I am doing the following:
11
36988
by: J055 | last post by:
Hi I have a dropdown control which is constructed in another dropdown control SelectedIndexChanged event protected void ddlParamType_SelectedIndexChanged(object sender, EventArgs e) { // some other code DropDownList ddlGroups = new DropDownList(); ddlGroups.SelectedIndexChanged += new
3
9846
by: =?Utf-8?B?ZGVuIDIwMDU=?= | last post by:
Hi, Trouble in retaining values of dropdownlist, textboxes, and other controls when dropdownlist selectedindexchanged event is triggered, the controls are inside a user control and this user control inside a parent user control with an update panel. Can you guys help me hwo to retain the values. I have set EnableViewState to true. Where is correct page event to store entered and selected values before the values on controls are...
3
1290
by: Mark B | last post by:
I have an MCMS website that I inherited. It was originally built in .NET 1.1 and then ported to .NET 2.0. They built it with inherited base classes to mimic what is now done with master pages. So much for the background. I'm building a new page that's pulling information from a database. The initial input has a dropdown list that populates dynamically and a couple labels that I'm using for housekeeping duties. The problem is that neither...
3
3832
by: =?Utf-8?B?Y21lZWsxXzE5OTk=?= | last post by:
Hello, On a webpage, create an UpdatePanel with two DropDownLists. Set AutoPostBack of DropDownList1 to true. In the SelectedIndexChanged method, refill DropDownList2 and set the focus to DropDownList1 using the ScriptManager SetFocus method. Use the Visual Studio debugger. Set a breakpoint on in the (!IsPostBack) part of the PageLoad method. Start the web application and continue after the breakpoint has been reached.
6
4277
by: shashi shekhar singh | last post by:
Respected Sir, I have to create multiple dynamic dropdownlist boxes and add items dynamically in <asp:table> server control but problem occurs , i.e. except of fist dropdown list no dropdownlist boxes are generating a postback.here is a code . protected void Page_Load(object sender, EventArgs e) { int selected_question = (int)Session; if (!Page.IsPostBack) { display_blueprint(); string...
0
8946
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9449
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9182
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6735
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6031
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3261
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2724
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.