473,322 Members | 1,347 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,322 software developers and data experts.

another problem with viewstate

Hi,

i have just read some threads about viewstate and wanted to test myself. But
there must be something i don't undertstand, because when i submit the form
with EnableViewState="false", i get the values back.
It seems that EnableViewState="false" has no influence because 'false' or
'true', it does not make any difference.
I thought that with 'false', i wouldn't get the values back.

Please look at the code here:
Thanks you
AlexC
<%@ Page Language="VB" EnableViewState="false" AutoEventWireup="false"
CodeFile="test.aspx.vb" Inherits="test" %>

<form id="frmViewState" runat="server">

Typ your name:
<asp:TextBox id="txtName" runat="server" />
Take a color:
<asp:DropDownList id="ddlColor" runat="server">
<asp:ListItem>Red</asp:ListItem>
<asp:ListItem>Blue</asp:ListItem>
<asp:ListItem>Yelowl</asp:ListItem>
</asp:DropDownList>
<asp:button id="btnSubmit" text="submit"
onClick="btnSubmit_Click" runat="server" />
</form>

the code is:
Sub btnSubmit_Click(ByVal Sender As Object, ByVal E As EventArgs)
lblSentence.Text = txtName.Text & " selecteerde " _
& ddlColor.SelectedItem.Text
End Sub
May 24 '07 #1
5 1384
a controls render properties are stored in viewstate, but the postback
values are sent as seperate form item along with viewstate.

viewstate is loaded in oninit before the postback data is read. this
sets a controls properties to the render value as opposed to the
declared value.

in a textbox this allows the onchange to tell if the postback vlue is
different than the original value. you can still get onchange to work
without viewstate by saving in session the render value, and setting the
controls value in oninit to the saved value.

in dropdownlist, the items are stored in viewstate. if viewstate is
turned off and the items are loaded in codebehind rather than on the
page, they must be re-addded in the onint.

-- bruce (sqlwork.com)

AlexC wrote:
Hi,

i have just read some threads about viewstate and wanted to test myself. But
there must be something i don't undertstand, because when i submit the form
with EnableViewState="false", i get the values back.
It seems that EnableViewState="false" has no influence because 'false' or
'true', it does not make any difference.
I thought that with 'false', i wouldn't get the values back.

Please look at the code here:
Thanks you
AlexC
<%@ Page Language="VB" EnableViewState="false" AutoEventWireup="false"
CodeFile="test.aspx.vb" Inherits="test" %>

<form id="frmViewState" runat="server">

Typ your name:
<asp:TextBox id="txtName" runat="server" />
Take a color:
<asp:DropDownList id="ddlColor" runat="server">
<asp:ListItem>Red</asp:ListItem>
<asp:ListItem>Blue</asp:ListItem>
<asp:ListItem>Yelowl</asp:ListItem>
</asp:DropDownList>
<asp:button id="btnSubmit" text="submit"
onClick="btnSubmit_Click" runat="server" />
</form>

the code is:
Sub btnSubmit_Click(ByVal Sender As Object, ByVal E As EventArgs)
lblSentence.Text = txtName.Text & " selecteerde " _
& ddlColor.SelectedItem.Text
End Sub

May 25 '07 #2
the view state is not responsible for having TextBoxes, CheckBoxes,
DropDownLists, and other Web controls remember their values across postback.
so whether you set false or ture to the viewstate property you can get the
value back.
May 25 '07 #3
Thanks both for your explanation, and forgive me if i'm not sure to
undertsand everything, but then, if the viewstate is not responsible for
rememberng their values, for what is viewstate well responsibel then in this
present case?
"gorilla" <go*****@discussions.microsoft.comschreef in bericht
news:07**********************************@microsof t.com...
the view state is not responsible for having TextBoxes, CheckBoxes,
DropDownLists, and other Web controls remember their values across
postback.
so whether you set false or ture to the viewstate property you can get the
value back.

May 25 '07 #4
On May 25, 8:49 am, "AlexC" <a...@cv.sdwrote:
Thanks both for your explanation, and forgive me if i'm not sure to
undertsand everything, but then, if the viewstate is not responsible for
rememberng their values, for what is viewstate well responsibel then in this
present case?

"gorilla" <gori...@discussions.microsoft.comschreef in berichtnews:07**********************************@m icrosoft.com...
the view state is not responsible for having TextBoxes, CheckBoxes,
DropDownLists, and other Web controls remember their values across
postback.
so whether you set false or ture to the viewstate property you can get the
value back.
The viewstate stores a list of properties for all of the controls on a
page so that these properties can be repopulated automatically when a
page is displayed after postback. Viewstate is not responsible for
posting the form values during the postback, i.e. you would be able to
access the value of any inputs on the page with postback enabled.

An excellent article on viewstate can be found at:
http://weblogs.asp.net/infinitiesloo...Viewstate.aspx

If you are unsure about any aspect of viewstate this is well worth a
read and also has information on helping to reduce overhead on
viewstate

May 25 '07 #5
Thanks

"phvfl183" <ph******@googlemail.comschreef in bericht
news:11*********************@g4g2000hsf.googlegrou ps.com...
On May 25, 8:49 am, "AlexC" <a...@cv.sdwrote:
>Thanks both for your explanation, and forgive me if i'm not sure to
undertsand everything, but then, if the viewstate is not responsible for
rememberng their values, for what is viewstate well responsibel then in
this
present case?

"gorilla" <gori...@discussions.microsoft.comschreef in
berichtnews:07**********************************@ microsoft.com...
the view state is not responsible for having TextBoxes, CheckBoxes,
DropDownLists, and other Web controls remember their values across
postback.
so whether you set false or ture to the viewstate property you can get
the
value back.

The viewstate stores a list of properties for all of the controls on a
page so that these properties can be repopulated automatically when a
page is displayed after postback. Viewstate is not responsible for
posting the form values during the postback, i.e. you would be able to
access the value of any inputs on the page with postback enabled.

An excellent article on viewstate can be found at:
http://weblogs.asp.net/infinitiesloo...Viewstate.aspx

If you are unsure about any aspect of viewstate this is well worth a
read and also has information on helping to reduce overhead on
viewstate

May 25 '07 #6

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

Similar topics

2
by: Prabhu Ram Prasath | last post by:
I have a series of 5 or 6 pages each containing some 10 or 12 text box controls. I need to recall the input given in first page at the last page. How should I use the viewstate collection to...
1
by: D. Shane Fowlkes | last post by:
I have a form in which clicking the submit button calls a "SaveData" sub rountine I wrote. The SaveData rountine inserts data from the form into a table and grabs the ID of the newly inserted...
0
by: Alessandro Rinaldi | last post by:
Hi all, what's wrong in this ? I added a simple Control with viewstate (ie : label, or my User control... ) dinamically in the controls collection of a TD cell created dynamically too, i lose...
1
by: Steph | last post by:
I am trying to save a simple integer value in ViewState. I set the value in the Page_Load() event and retrieve it in the function Page_Unload() event. The value seems to be set correctly, but...
2
by: sourabh | last post by:
Hi guys Till now i thougt I understood ViewState but as I was trying write my LoadViewState method i am sort of confused with what this ViewState is and what is its use. I have my LoadViewState...
2
by: sdrouins | last post by:
Hello, I had a really weird problem that occured on one of our site. (occur 2 times in 3 years) The client 1 have fill the form1 and submit it, for some reason the page was postback to the...
4
by: AviationDev | last post by:
We keep getting the following error: ----------------------------------------------------------------------------------------------- Final Exception System.Web.HttpUnhandledException: Exception...
2
by: Jarod | last post by:
Hey I change backColor of linkButton in my Page_Load: lbDoSth.BackColor = Color.Red; But I have multiView on this page. On one of the views I have detailsView. When I add a new row a set...
0
by: JP2006 | last post by:
I'm having a major pain with retrieving ViewState info after a postback event. I am trying to persist a string contained in a label (label_AntiBot.Text) that is generated randomly on page load but...
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
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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: 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.