Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Setting the order of LoadViewState

Reply
Thread Tools

Setting the order of LoadViewState

 
 
lisa@starways.net
Guest
Posts: n/a
 
      04-08-2005
I have a server control. It has a Layout property, a Height property,
and a Width property. What happens in the Height and Width property
depends on the Layout.

Unfortunately, what seems to be happening is that when I run a page
that has my control in it, the Height and Width properties are
initialized from ViewState before the Layout property. As a result,
the Height and Width properties are assuming a Layout property of 0
(it's an enum property, and that's what you get when there's no value).

Is there a way that I can force my page to initialize the Layout
property first? I've tried moving it above them in the code, on the
chance that it's processing from the top down, but that didn't have any
effect.

Can anyone help?

Thanks,
Lisa

 
Reply With Quote
 
 
 
 
Steve Goodyear
Guest
Posts: n/a
 
      04-08-2005
Hi Lisa,

As a best practice you should re-consider the logic or timing when events
happen. During the LoadViewState phase you don't really want any logic to
occur because some properties might rely on others that load their ViewState
later. See if you can take the logic that relies on Layout and implement it
at the PreRender event instead.

Instead if you totally reject that idea, LoadViewState is dependent on the
order Controls are added to the Page control tree.

Cheers,
Steve Goodyear
Vancouver, Canada
 
Reply With Quote
 
 
 
 
Haacked
Guest
Posts: n/a
 
      04-08-2005
The ViewState doesn't guarantee the order that controls
are loaded and saved. Therefore, if the value of the
Layout property is dependent on the Height and Width, it
probably shouldn't be saved in the ViewState. You could
make it a property that is calculated when it is accessed.

If that is a problem for some reason, your best bet is to
have your server control override the LoadViewState()
method and load the values from the ViewState in the
correct order. That gives you total control.

Hope this helps.

Phil
http://haacked.com/

>-----Original Message-----
>I have a server control. It has a Layout property, a

Height property,
>and a Width property. What happens in the Height and

Width property
>depends on the Layout.
>
>Unfortunately, what seems to be happening is that when I

run a page
>that has my control in it, the Height and Width

properties are
>initialized from ViewState before the Layout property.

As a result,
>the Height and Width properties are assuming a Layout

property of 0
>(it's an enum property, and that's what you get when

there's no value).
>
>Is there a way that I can force my page to initialize

the Layout
>property first? I've tried moving it above them in the

code, on the
>chance that it's processing from the top down, but that

didn't have any
>effect.
>
>Can anyone help?
>
>Thanks,
>Lisa
>
>.
>

 
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
LoadViewState works only when datagrid or datalist control not when TextBoxa and other server controls? SSW ASP .Net 2 11-12-2003 03:07 AM
LoadViewState SSW ASP .Net 0 11-07-2003 09:49 AM
in LoadViewState() : ViewState is empty after page reloads the 2nd time Christian ASP .Net 0 07-17-2003 08:58 AM
in LoadViewState() : ViewState is empty ?? Christian ASP .Net 0 07-16-2003 07:12 PM
Help w/ LoadViewState and SaveViewState subs Showjumper ASP .Net 0 06-26-2003 01:38 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57