Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Re: Declaration variables

Reply
Thread Tools

Re: Declaration variables

 
 
Kevin Spencer
Guest
Posts: n/a
 
      08-27-2003
It's hard to tell from your message WHEN and WHERE you want to re-use these
variables, and that makes all the difference in terms of how you would
store/persist them. The Page class is re-instantiated and destroyed with
each Page request. So, if you don't need the values to survive PostBacks
(for example, if you want to use them in the Page_Init and Page_Load
methods), you can store them in the class as fields or properties. If you
need them across PostBacks, but only within the one Page, you can store them
in ViewState. ViewState is maintained by using a hidden form field in the
client, which is posted back to the server and updated with each PostBack.
Note, however, that, as ViewState is rendered in a hidden form field in the
Page, it's not a good idea to store anything very large in there. If you
want to use them across multiple pages, but only for a single user Session,
then storing them is SessionState makes sense. If you want them to be
globally available to all Pages and all user Sessions, you can store them in
ApplicationState.

There are a few other places as well, but this hits the high points.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
The more I learn, the less I know.

"Micke Palm" <> wrote in message
news:...
> Hello there!
>
> My problem is maybe not a problem I need a better solution instead.
>
> The scenenario is this...
> When you came to a page I call the SQL and get some parameters. I want to
> stored these parameters like tablename and filename in a variable so I can
> use it everywhere in this page. The only way is to save it in sessions or
> viewstate, but I think it's get a better way to save this. Maybe in a

public
> variable or something??
>
> Is viewstate unique? I think so...
>
> Any suggestions of this elemantary .net programming?
>
> /regards, micke
>
>



 
Reply With Quote
 
 
 
 
Micke Palm
Guest
Posts: n/a
 
      08-27-2003
Thanks! Exactly what I need to know! In my case it is postbacks so I
think I can use viewstate for this.

/regards, micke

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
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
Can a static function declaration conflict with a non-static declaration? nospam_timur@tabi.org C Programming 4 12-12-2006 10:26 PM
maxplusII error: a deferred constant declaration without a full declaration is not supported Noah VHDL 5 04-07-2006 02:34 PM
"virtual outside class declaration" and "declaration does not declare anything" kelvSYC C++ 6 05-17-2005 08:58 AM
Function declaration in class declaration Ovidesvideo C++ 4 12-10-2004 06:36 PM
Intel C++ 8.0 : declaration hides declaration Alex Vinokur C++ 4 04-05-2004 09:49 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