You are providing your control, which is a separate class, a reference to the
current HttpContext so it can access the page's Session object.
Cheers,
Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
"RSH" wrote:
> Thanks!
>
> That did the trick...although i'm not sure why that worked?
>
>
> "Peter Bromberg [C# MVP]" <> wrote in message
> news:3D9F656C-A1ED-4829-A92B-...
> > How about:
> >
> > LoadContent(Value, Trim(HttpContext.Current.Session("UserType")))
> >
> > Peter
> >
> >
> > --
> > Co-founder, Eggheadcafe.com developer portal:
> > http://www.eggheadcafe.com
> > UnBlog:
> > http://petesbloggerama.blogspot.com
> >
> >
> >
> >
> > "RSH" wrote:
> >
> >>
> >> 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
> >>
> >>
> >>
>
>
>