Reading a Session Variable from a Dynamically created control

R

RSH

Hi,

I have a situation where I have a page built in .Net 1.1 that I have a
PlaceHolder in the Design. From the CodeBehind I am dynamically referencing
a user control.

This is a snippet from the the CodeBehind from that page:

Dim mc As MainContent = New MainContent <----User Created Control

Select Case Trim(Session("UserType"))

Case "Corp"

mc.DisplayContent = "TESTCO"

Case "Service Center"

mc.DisplayContent = "TESTSC"

End Select

PlaceHolder1.Controls.Add(mc)


The Control has a property called DisplayContent that accepts the ContentID
for that page. The code in the ascx file is simple...basically there is a
placeholder in the Design view, and in the codebehind Property I am calling
a function. That code looks like this:

Public Property DisplayContent() As String

Get

Return DisplayContent

End Get

Set(ByVal Value As String)

If Len(Trim(Session("UserType"))) > 0 Then

LoadContent(Value, Trim(Session("UserType")))

End If

End Set

End Property



The problem is that for some reason The "Session("UserType") = Nothing" when
I step through the code in the control which doesn't make any sense because
the session variable exists in the select statement on the aspx page that
calls the control.

How do I get the control to see the Session variables?

Thanks!

Ron
 

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

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,276
Latest member
Sawatmakal

Latest Threads

Top