accessing session and viewstate from custom web controls

A

Agustin Sanchez

I know it is possible to use Session and Viewstate objects from a Web User
Control, as it's almost the same as a standard aspx page. I'd like to know
if the same functionality is available from Custom Web Controls.

Thanks in advance.

Agustin Sanchez
 
T

Teemu Keiski

The ViewState as with web user controls but your custom control just derives
from System.Web.UI.Control or perhaps System.Web.UI.WebControls.WebControl.
The control has it's own ViewState property (of type System.Web.UI.StateBag)
when this is fullfilled.

For the session you need to access via controls Context property. That is

Context.Session["key"]="value";

and so on

--
Teemu Keiski
MCP,Designer/Developer
Mansoft tietotekniikka Oy
http://www.mansoft.fi

AspInsiders Member, www.aspinsiders.com
ASP.NET Forums Moderator, www.asp.net
AspAlliance Columnist, www.aspalliance.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top