PC Review


Reply
Thread Tools Rate Thread

another problem with viewstate

 
 
AlexC
Guest
Posts: n/a
 
      24th May 2007
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:
<aspropDownList id="ddlColor" runat="server">
<asp:ListItem>Red</asp:ListItem>
<asp:ListItem>Blue</asp:ListItem>
<asp:ListItem>Yelowl</asp:ListItem>
</aspropDownList>
<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


 
Reply With Quote
 
 
 
 
bruce barker
Guest
Posts: n/a
 
      25th May 2007
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:
> <aspropDownList id="ddlColor" runat="server">
> <asp:ListItem>Red</asp:ListItem>
> <asp:ListItem>Blue</asp:ListItem>
> <asp:ListItem>Yelowl</asp:ListItem>
> </aspropDownList>
> <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
>
>

 
Reply With Quote
 
=?Utf-8?B?Z29yaWxsYQ==?=
Guest
Posts: n/a
 
      25th May 2007
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.
 
Reply With Quote
 
AlexC
Guest
Posts: n/a
 
      25th May 2007
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" <(E-Mail Removed)> schreef in bericht
news:071F9461-0938-4DD1-B03D-(E-Mail Removed)...
> 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.



 
Reply With Quote
 
phvfl183
Guest
Posts: n/a
 
      25th May 2007
On May 25, 8:49 am, "AlexC" <a...@cv.sd> wrote:
> 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.com> schreef in berichtnews:071F9461-0938-4DD1-B03D-(E-Mail Removed)...
>
> > 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

 
Reply With Quote
 
AlexC
Guest
Posts: n/a
 
      25th May 2007
Thanks

"phvfl183" <(E-Mail Removed)> schreef in bericht
news:(E-Mail Removed)...
> On May 25, 8:49 am, "AlexC" <a...@cv.sd> wrote:
>> 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.com> schreef in
>> berichtnews:071F9461-0938-4DD1-B03D-(E-Mail Removed)...
>>
>> > 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
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Loading usercontrols, viewstate problem, slighly different from all others "viewstate uc problems" please help... ujjc001 Microsoft ASP .NET 0 27th Jul 2005 02:52 PM
Viewstate problem? =?Utf-8?B?Vmtv?= Microsoft ASP .NET 1 11th Jan 2005 07:22 AM
Re: ViewState Problem ashelley@inlandkwpp.com Microsoft ASP .NET 0 29th Jun 2004 04:43 PM
ASP.NET Viewstate problem KK Microsoft ASP .NET 1 23rd Jan 2004 07:49 AM
Hi.. I've a problem about ViewState. zimzion Microsoft ASP .NET 1 16th Jul 2003 12:41 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:26 AM.