Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > viewstate=false doesn't work

Reply
Thread Tools

viewstate=false doesn't work

 
 
Trapulo
Guest
Posts: n/a
 
      03-03-2005
I've a datagrid and I try to disable viewstate to avoid a lot of hidden data
in the post field (about 100kb). But this doesn't work!

<aspataGrid id="dgExhibitionServices" runat="server" Width="520px"
Height="17px" AutoGenerateColumns="False"
EnableViewState="False" >

If this is false or not, the viewstate and page's size don't change!
What is the problem?

My datagrid is inside a usercontrol, and the main webform contains this
userscontrol. I've this problem with all controls on my page.

thanks


 
Reply With Quote
 
 
 
 
Scott M.
Guest
Posts: n/a
 
      03-03-2005
Alvin, if you turn viewstate off for a DataGrid, then, yes the data must
still be transferred to the client, but no, that data would not be persisted
in VeiwState. In other words, once you turn off ViewState for a DataGrid,
you will notice a substantial decrease in the length of the ViewState
string. ViewState is not how the data reaches the DataGrid, so turning it
off would mean that the data would have to be re-fetched from somewhere but
the ViewState hidden form field would not be holding on to any of it.


"Alvin Bruney [Microsoft MVP]" <www.lulu.com/owc> wrote in message
news:O6X%(E-Mail Removed)...
> I'm not sure what you are expecting to happen, the data still needs to be
> loaded into the datagrid and moved to the client. Turning off viewstate
> prevents a round-trip of that data, but there will still be a single trip
> which is what you are seeing.
>
> By the way, strictly speaking, the datagrid does not store its data in
> viewstate, the datagrid does contain child controls (tablecells etc) that,
> in turn, store its data in viewstate.
>
> What are you trying to accomplish?
>
> --
> Regards
> Alvin Bruney
> [Shameless Author Plug]
> The Microsoft Office Web Components Black Book with .NET
> available at www.lulu.com/owc
> --------------------------------------------------
>
>
> "Trapulo" <(E-Mail Removed)> wrote in message
> news:%23XQ7Bu%(E-Mail Removed)...
>> I've a datagrid and I try to disable viewstate to avoid a lot of hidden
>> data
>> in the post field (about 100kb). But this doesn't work!
>>
>> <aspataGrid id="dgExhibitionServices" runat="server" Width="520px"
>> Height="17px" AutoGenerateColumns="False"
>> EnableViewState="False" >
>>
>> If this is false or not, the viewstate and page's size don't change!
>> What is the problem?
>>
>> My datagrid is inside a usercontrol, and the main webform contains this
>> userscontrol. I've this problem with all controls on my page.
>>
>> thanks
>>
>>

>
>



 
Reply With Quote
 
 
 
 
Trapulo
Guest
Posts: n/a
 
      03-04-2005
Yes: I think I may have a great decrease of viewstate string. But with or
without enableviewstate=false, I've the same (great) length..

"Scott M." <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Alvin, if you turn viewstate off for a DataGrid, then, yes the data must
> still be transferred to the client, but no, that data would not be

persisted
> in VeiwState. In other words, once you turn off ViewState for a DataGrid,
> you will notice a substantial decrease in the length of the ViewState
> string. ViewState is not how the data reaches the DataGrid, so turning it
> off would mean that the data would have to be re-fetched from somewhere

but
> the ViewState hidden form field would not be holding on to any of it.
>



 
Reply With Quote
 
Andrew Robinson
Guest
Posts: n/a
 
      03-04-2005
I have used the following to eliminate viewstate on the client. Works well
where there is a slow link and large viewstate. It could lead to issues in
other areas. Mainly that you are loading up the server cache. You are
shifting the storage from the client back to the server. You could modify
this so that is used a session id and stored the viewstate in SQL. Maybe
more than you were looking for. I found this code elseware, but modified it
a bit.

-Andrew

>>>>


Using System.Web.Cache;

protected override void SavePageStateToPersistenceMedium(object
viewStateObject)
{
string viewStateKey = "VIEWSTATE_" + Guid.NewGuid();
Cache.Add(viewStateKey, viewStateObject, null,
DateTime.Now.AddMinutes(Session.Timeout), TimeSpan.Zero,
CacheItemPriority.Default, null);
RegisterHiddenField("__VIEWSTATE_KEY", viewStateKey);
RegisterHiddenField("__VIEWSTATE", "");
}

protected override object LoadPageStateFromPersistenceMedium()
{
string viewStateKey = Request.Form["__VIEWSTATE_KEY"];
if (!viewStateKey.StartsWith("VIEWSTATE_"))
{
throw new Exception("Invalid viewstate key:" +
viewStateKey);
}

object viewStateObject = Cache[viewStateKey];
Cache.Remove(viewStateKey);

return viewStateObject;
}

<<<<<<<<<



"Trapulo" <(E-Mail Removed)> wrote in message
news:#XQ7Bu#(E-Mail Removed)...
> I've a datagrid and I try to disable viewstate to avoid a lot of hidden

data
> in the post field (about 100kb). But this doesn't work!
>
> <aspataGrid id="dgExhibitionServices" runat="server" Width="520px"
> Height="17px" AutoGenerateColumns="False"
> EnableViewState="False" >
>
> If this is false or not, the viewstate and page's size don't change!
> What is the problem?
>
> My datagrid is inside a usercontrol, and the main webform contains this
> userscontrol. I've this problem with all controls on my page.
>
> thanks
>
>



 
Reply With Quote
 
Scott M.
Guest
Posts: n/a
 
      03-06-2005
I didn't say you were wrong, but you said "I'm not sure what you are
expecting to happen" and it seemed obvious that what the OP was looking for
was a way to take the persisted data out of the ViewState hidden form field.
So, my reply was simply to clarify what data gets transferred where and what
the OP hopes to accomplish (answer to your question).


"Alvin Bruney [Microsoft MVP]" <www.lulu.com/owc> wrote in message
news:%(E-Mail Removed)...
> True. I'm not sure where you think I went wrong. Care to point it out?
>
> --
> Regards
> Alvin Bruney
> [Shameless Author Plug]
> The Microsoft Office Web Components Black Book with .NET
> available at www.lulu.com/owc
> --------------------------------------------------
>
>
> "Scott M." <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Alvin, if you turn viewstate off for a DataGrid, then, yes the data must
>> still be transferred to the client, but no, that data would not be
>> persisted in VeiwState. In other words, once you turn off ViewState for
>> a DataGrid, you will notice a substantial decrease in the length of the
>> ViewState string. ViewState is not how the data reaches the DataGrid, so
>> turning it off would mean that the data would have to be re-fetched from
>> somewhere but the ViewState hidden form field would not be holding on to
>> any of it.
>>
>>
>> "Alvin Bruney [Microsoft MVP]" <www.lulu.com/owc> wrote in message
>> news:O6X%(E-Mail Removed)...
>>> I'm not sure what you are expecting to happen, the data still needs to
>>> be loaded into the datagrid and moved to the client. Turning off
>>> viewstate prevents a round-trip of that data, but there will still be a
>>> single trip which is what you are seeing.
>>>
>>> By the way, strictly speaking, the datagrid does not store its data in
>>> viewstate, the datagrid does contain child controls (tablecells etc)
>>> that, in turn, store its data in viewstate.
>>>
>>> What are you trying to accomplish?
>>>
>>> --
>>> Regards
>>> Alvin Bruney
>>> [Shameless Author Plug]
>>> The Microsoft Office Web Components Black Book with .NET
>>> available at www.lulu.com/owc
>>> --------------------------------------------------
>>>
>>>
>>> "Trapulo" <(E-Mail Removed)> wrote in message
>>> news:%23XQ7Bu%(E-Mail Removed)...
>>>> I've a datagrid and I try to disable viewstate to avoid a lot of hidden
>>>> data
>>>> in the post field (about 100kb). But this doesn't work!
>>>>
>>>> <aspataGrid id="dgExhibitionServices" runat="server" Width="520px"
>>>> Height="17px" AutoGenerateColumns="False"
>>>> EnableViewState="False" >
>>>>
>>>> If this is false or not, the viewstate and page's size don't change!
>>>> What is the problem?
>>>>
>>>> My datagrid is inside a usercontrol, and the main webform contains this
>>>> userscontrol. I've this problem with all controls on my page.
>>>>
>>>> thanks
>>>>
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

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
RE;Kontki if you delete kontiki any program you loaded with it in it 'will not work I have tried it with three programs and none work anymore (if you se it just stop download) 1-Twitch Computer Support 5 04-23-2009 02:45 PM
MS work around on text wrapping in a datagrid does not work TB ASP .Net 2 02-22-2006 10:34 PM
Hi I am new to asp i can not get it to work on xp pro sp2 even though the localhost work but asp pages dont so can some one help craig dicker ASP .Net 9 07-07-2005 11:52 AM
Re: Those cute little "WORK-SAFE" / "NOT WORK-SAFE" tags that people put in the Subject headers of their posts... Soapy Digital Photography 1 08-16-2004 12:07 PM
Re: Those cute little "WORK-SAFE" / "NOT WORK-SAFE" tags that people put in the Subject headers of their posts... Soapy Digital Photography 1 08-16-2004 06:24 AM



Advertisments