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 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
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.
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.
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
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: AviationDev |
last post by:
We keep getting the following error:
-----------------------------------------------------------------------------------------------
Final Exception
System.Web.HttpUnhandledException: Exception...
|
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...
|
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...
|
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...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
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...
|
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...
|
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...
|
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...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
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....
|
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...
| |