473,657 Members | 2,686 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

viewstate = false doesn't work

i've got a simple page with a dropdown list of employees and a series of
checkboxs showing their skills. the checkboxs are created dynamically from a
sql statement and viewstate = false is set on each one. once the dropdown
changes from one employee to another, the checkboxes are all recreated and i
check the database to see if that particular employee has that skill. if so,
i set the checkbox's checked state to true. however, when i look at the
newly rendered page, the only checkboxs that are checked are those that i've
manully checked. i could set the viewstate in the page directive, but that
applies to all controls and i want the page to remember which employee was
last selected.

so, it looks like my script is initializing the checkboxes to the correct
value initially, but after that .net steps in and sets them back to what was
last posted even though i've set viewstate to all checkbox controls to
false.

anybody got any ideas what i'd doing wrong here?

tks
Jun 21 '07 #1
2 2206
Field values are not stored in the viewstate. By design a web page post
field values to the server. The viewstate was created to store other values.
So IMO your controls are just reinitialized from postback values.

Double check your code. You likely forgot to initialize the values from the
db after a postback ( it's likely that usually you don't bind again on a
postback because the data are what you want to show but in this particular
case the postback change the current set of data you wan't to display so you
should bind again to your data).

--
Patrice
"Dica" <ge*****@hotmai l.coma écrit dans le message de news:
%Wxei.6081$xk5. 4250@edtnps82.. .
i've got a simple page with a dropdown list of employees and a series of
checkboxs showing their skills. the checkboxs are created dynamically from
a sql statement and viewstate = false is set on each one. once the
dropdown changes from one employee to another, the checkboxes are all
recreated and i check the database to see if that particular employee has
that skill. if so, i set the checkbox's checked state to true. however,
when i look at the newly rendered page, the only checkboxs that are
checked are those that i've manully checked. i could set the viewstate in
the page directive, but that applies to all controls and i want the page
to remember which employee was last selected.

so, it looks like my script is initializing the checkboxes to the correct
value initially, but after that .net steps in and sets them back to what
was last posted even though i've set viewstate to all checkbox controls to
false.

anybody got any ideas what i'd doing wrong here?

tks

Jun 21 '07 #2

"Patrice" <http://www.chez.com/scribe/wrote in message
news:%2******** ********@TK2MSF TNGP06.phx.gbl. ..
Field values are not stored in the viewstate. By design a web page post
field values to the server. The viewstate was created to store other
values. So IMO your controls are just reinitialized from postback values.
yes. that's exactly what i'm seeing. what i'm trying to do is stop the asp
net engine from repopulating these fields based on the posted back data and
instead use the values i'm assigning as the dynamically created controls are
initialized. i modified my page so that when the user drop down list is
changed (causing a postback event) i capture the selected user to session
and then response.redire ct back to the same page. then, within page_load i
get the selected user and call my routine to recreate the dynamic controls
with the appropriate values. this works fine. so, it's something in the
postback event i need to control, but how? if the solution is to rebind my
data, in which event handler should it go? in other words, which event would
fire after .net is done repopulating the form fields?

tks
>
Double check your code. You likely forgot to initialize the values from
the db after a postback ( it's likely that usually you don't bind again on
a postback because the data are what you want to show but in this
particular case the postback change the current set of data you wan't to
display so you should bind again to your data).
>
--
Patrice
"Dica" <ge*****@hotmai l.coma écrit dans le message de news:
%Wxei.6081$xk5. 4250@edtnps82.. .
>i've got a simple page with a dropdown list of employees and a series of
checkboxs showing their skills. the checkboxs are created dynamically
from a sql statement and viewstate = false is set on each one. once the
dropdown changes from one employee to another, the checkboxes are all
recreated and i check the database to see if that particular employee has
that skill. if so, i set the checkbox's checked state to true. however,
when i look at the newly rendered page, the only checkboxs that are
checked are those that i've manully checked. i could set the viewstate in
the page directive, but that applies to all controls and i want the page
to remember which employee was last selected.

so, it looks like my script is initializing the checkboxes to the correct
value initially, but after that .net steps in and sets them back to what
was last posted even though i've set viewstate to all checkbox controls
to false.

anybody got any ideas what i'd doing wrong here?

tks


Jun 22 '07 #3

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

Similar topics

9
21639
by: John Kirksey | last post by:
I have a page that uses an in-place editable DataGrid that supports sorting and paging. EnableViewState is turned ON. At the top of the page are several search fields that allow the user to filter the results in the grid. Say you filter the grid for records that have a certain condition set to "NO" (in this case a checkbox). In this scenario the search returns one result. If I then check the checkbox ("YES") and save it, I now get my message...
3
2639
by: Steve Drake | last post by:
All, I have a CONTROL that contains 1 control (Control ONE), the 1 control that it can contain 1 or 2 control (Control A and B). Control A, raises and event and Control ONE receives this event and this causes control B to be created, when this is done the VIEWSTATE is lost for CONTROL B. In the EVENT that causes CONTROL B to be created I have to set
1
4110
by: Lisa | last post by:
I have a web app that gets a recordset from the database and fills a grid. You can drilldown from this table to a detail table. Because the tables sometimes get huge, and because I have to go back to the database again every time I postback anyway, I wanted to disable ViewState in the grids. Just to minimize the amount of stuff that gets downloaded to the client. The problem is that none of the postbacks work. They postback, but...
1
5428
by: olduncleamos | last post by:
Hello all, I am experimenting with the repeater control and ran into something that I wasn't expecting. I would appreciate if the experts can confirm or correct my understanding. Here is a fragment of a very simple page that I wrote that will drill down into the displayed item. The result is to be display on the same page so that the user can keep on drilling down:
6
2739
by: John | last post by:
Hi all, I am using dynamic user controls within my web app and these controls are loaded into placeholders via the LoadControl method. My problem is this: I have usercontrolA loaded into a placholder and the user clicks on a specific control outside of the usercontrol and some Javascript is run where a hidden variable is changed to reflect another usercontrol (usercontrolB).
4
2211
by: Sven Jacobs | last post by:
Hello everybody! Imagine a form with several TextBox WebControls and two buttons "New" which should clear the form and "Save". On reloading or leaving the page which holds the form the TextBoxes should be cleared so I've disabled the ViewStates of these TextBoxes by setting the EnableViewState property to false. The method which is bound to the OnClick event of the "New" button is empty. When clicked a PostBack occurs which,...
10
3077
by: Robert | last post by:
I have an app that was originally 1.1, now migrated to 2.0 and have run into some sporadic viewstate errors...usually saying the viewstate is invalid, eventvalidation failed or mac error. My web config does specify a machinekey setting: <machineKey validationKey="447C05E8B3A71401CC4CAE5513A7F1A3494A3618EE819316AAD1D58433F236A759D66FB4154500E01EB4E1BC1DE42046E2D652D391CB8367A1649438867A02EB"...
10
1626
by: Lloyd Dupont | last post by:
When you define UserControl in source code the sample I see are often like that: ============ public string Text { get { String s = (String)ViewState; return ((s == null) ? String.Empty : s); }
1
1663
by: Christophe Peillet | last post by:
I have a CompositeControl with two types of properties: 1.) Mapped Properties that map directly to a child control's properties (ex.: this.TextboxText = m_txt.Text). These properties are handled by their underlying classes (such as the TextBox control), and are not persisted by me. 2.) Unique Properties that don't map directly and are persisted in ViewState (ex.: this.LabelPosition, which specifies where on the form the label should be...
0
8319
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8837
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...
1
8512
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8612
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...
0
7347
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6175
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
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1969
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1732
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.