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
>
>