473,473 Members | 1,977 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Session Variables not available in UserControl

I have some user controls defined that represent a common header and footer
for a particular site. the footer contains links with querystring parameters
based on session variables. The problem is, I cannot access the session
variables within my user control. The user controls work perfectly
otherwise. Example code included.

Feb 2 '06 #1
3 3495
To follow up. Here is the example from my footer. Like I said, the
usercontrol works fine, but the session variables are empty.
<%@ Control Language="VB" EnableViewState="False" %>
</td>
</tr>
</table>
<img src="images/index_01.jpg" width=100% height=6><br>
<table border="0" width="100%" id="table1" cellspacing="0" cellpadding="0">
<tr>
<td align="center">
<%if Session("dept_id") = 0 then %>
<a href="logon.aspx?ErrorCode=Session"><asp:Label runat="server"
ForeColor="Blue" Font-Bold=True Font-Size="14px" ID="Home" Text="HOME"/></a>
<%else%>
<a href="dept_cycles.aspx?dept_id="<%=session("dept_i d")%>"><asp:Label
runat="server" ForeColor="Blue" Font-Bold=True Font-Size="14px" ID="Home2"
Text="HOME"/></a>
<%end if%>
</td>
<td align="center"><asp:Label runat="server" ForeColor="Blue"
Font-Bold=True Font-Size="14px" ID="Plans" Text="PLANS"/></td>
<td align="center"><asp:Label runat="server" ForeColor="Blue"
Font-Bold=True Font-Size="14px" ID="Summ" Text="EXEC SUMMARY"/></td>
<td align="center"><asp:Label runat="server" ForeColor="Blue"
Font-Bold=True Font-Size="14px" ID="Fund" Text="FUNDING"/></td>
<td align="center"><asp:Label runat="server" ForeColor="Blue"
Font-Bold=True Font-Size="14px" ID="Goals" Text="GOALS"/></td>
</tr>
</table>
</td>
</tr>
</TABLE>

"Lee Moore" <le******@hotmail.com> wrote in message
news:Of**************@tk2msftngp13.phx.gbl...
I have some user controls defined that represent a common header and footer
for a particular site. the footer contains links with querystring
parameters based on session variables. The problem is, I cannot access the
session variables within my user control. The user controls work perfectly
otherwise. Example code included.

Feb 2 '06 #2
Lee,
Try using:

If Not HttpContext.Current.Session("dept_id") Is Nothing Then
If HttpContext.Current.Session("dept_id") =0 then

' your cool code here

End if
End if
if it still comes up empty, then most likely the Session item is null.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Lee Moore" wrote:
To follow up. Here is the example from my footer. Like I said, the
usercontrol works fine, but the session variables are empty.
<%@ Control Language="VB" EnableViewState="False" %>
</td>
</tr>
</table>
<img src="images/index_01.jpg" width=100% height=6><br>
<table border="0" width="100%" id="table1" cellspacing="0" cellpadding="0">
<tr>
<td align="center">
<%if Session("dept_id") = 0 then %>
<a href="logon.aspx?ErrorCode=Session"><asp:Label runat="server"
ForeColor="Blue" Font-Bold=True Font-Size="14px" ID="Home" Text="HOME"/></a>
<%else%>
<a href="dept_cycles.aspx?dept_id="<%=session("dept_i d")%>"><asp:Label
runat="server" ForeColor="Blue" Font-Bold=True Font-Size="14px" ID="Home2"
Text="HOME"/></a>
<%end if%>
</td>
<td align="center"><asp:Label runat="server" ForeColor="Blue"
Font-Bold=True Font-Size="14px" ID="Plans" Text="PLANS"/></td>
<td align="center"><asp:Label runat="server" ForeColor="Blue"
Font-Bold=True Font-Size="14px" ID="Summ" Text="EXEC SUMMARY"/></td>
<td align="center"><asp:Label runat="server" ForeColor="Blue"
Font-Bold=True Font-Size="14px" ID="Fund" Text="FUNDING"/></td>
<td align="center"><asp:Label runat="server" ForeColor="Blue"
Font-Bold=True Font-Size="14px" ID="Goals" Text="GOALS"/></td>
</tr>
</table>
</td>
</tr>
</TABLE>

"Lee Moore" <le******@hotmail.com> wrote in message
news:Of**************@tk2msftngp13.phx.gbl...
I have some user controls defined that represent a common header and footer
for a particular site. the footer contains links with querystring
parameters based on session variables. The problem is, I cannot access the
session variables within my user control. The user controls work perfectly
otherwise. Example code included.


Feb 2 '06 #3
No luck. Here is the exact code in use now...

<%If HttpContext.Current.Session("dept_id") Is Nothing Then%>
<a href="logon.aspx?ErrorCode=Session"><asp:Label runat="server"
ForeColor="Blue" Font-Bold=True Font-Size="14px" ID="Home"
Text="HOME"/></a>
<%else%>
<a
href="dept_cycles.aspx?dept_id="<%=HttpContext.Cur rent.Session("dept_id")%>"><asp:Label
runat="server" ForeColor="Blue" Font-Bold=True
Font-Size="14px" ID="Home2" Text="HOME"/></a>
<%end if%>

The link shows up as ...

dept_cycles?dept_id=

The code for the header of the page includes the code...

<%if session("FullName") <> "" then
response.write(session("FullName"))
else
response.write("Not Logged On")
end if%>
<br>
Dept:
<%if session("dept_name") <> "" then
response.write(session("dept_name"))
end if%>
The header works fine. I cannot understand why the footer cannot access the
values of session variables. Very Strange.
Basically, if the session has expired, then I would like for the link to
take them to the logon page
"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in message
news:A5**********************************@microsof t.com...
Lee,
Try using:

If Not HttpContext.Current.Session("dept_id") Is Nothing Then
If HttpContext.Current.Session("dept_id") =0 then

' your cool code here

End if
End if
if it still comes up empty, then most likely the Session item is null.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Lee Moore" wrote:
To follow up. Here is the example from my footer. Like I said, the
usercontrol works fine, but the session variables are empty.
<%@ Control Language="VB" EnableViewState="False" %>
</td>
</tr>
</table>
<img src="images/index_01.jpg" width=100% height=6><br>
<table border="0" width="100%" id="table1" cellspacing="0"
cellpadding="0">
<tr>
<td align="center">
<%if Session("dept_id") = 0 then %>
<a href="logon.aspx?ErrorCode=Session"><asp:Label runat="server"
ForeColor="Blue" Font-Bold=True Font-Size="14px" ID="Home"
Text="HOME"/></a>
<%else%>
<a
href="dept_cycles.aspx?dept_id="<%=session("dept_i d")%>"><asp:Label
runat="server" ForeColor="Blue" Font-Bold=True Font-Size="14px"
ID="Home2"
Text="HOME"/></a>
<%end if%>
</td>
<td align="center"><asp:Label runat="server" ForeColor="Blue"
Font-Bold=True Font-Size="14px" ID="Plans" Text="PLANS"/></td>
<td align="center"><asp:Label runat="server" ForeColor="Blue"
Font-Bold=True Font-Size="14px" ID="Summ" Text="EXEC SUMMARY"/></td>
<td align="center"><asp:Label runat="server" ForeColor="Blue"
Font-Bold=True Font-Size="14px" ID="Fund" Text="FUNDING"/></td>
<td align="center"><asp:Label runat="server" ForeColor="Blue"
Font-Bold=True Font-Size="14px" ID="Goals" Text="GOALS"/></td>
</tr>
</table>
</td>
</tr>
</TABLE>

"Lee Moore" <le******@hotmail.com> wrote in message
news:Of**************@tk2msftngp13.phx.gbl...
>I have some user controls defined that represent a common header and
>footer
>for a particular site. the footer contains links with querystring
>parameters based on session variables. The problem is, I cannot access
>the
>session variables within my user control. The user controls work
>perfectly
>otherwise. Example code included.
>
>
>


Feb 3 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: VijayShankar | last post by:
Can u be more specific on your question Anyway its not like Session variables are available for sometime and not available for sometime. When your session starts it is very much available...
5
by: Phil Grimpo | last post by:
I have a very odd situation here. I have an administration page, where based on a users permissions, a recordset is called from the SQL server which has a list of paths to "Module Menus". Each of...
14
by: Paul Yanzick | last post by:
Hello, I am trying to develop a book tracking application for my capstone in school, and am running into a problem. The application is an ASP.Net application written in C#. The first page you...
6
by: Hans Kesting | last post by:
Hi, When the Session_OnEnd event fires, do the Session variables still exist? I want to do some cleanup (update some records in a database etc.), but then I need to know *which* recopds to...
4
by: PJ | last post by:
A particular page seems to be having issues with correctly setting Session variables. I am setting a couple of session variables on the Page_Unload event. While stepping through code, the...
14
by: Coleen | last post by:
Hi All :-) We have an APSX application using VB.net as the code behind, which uses one or two session variables per page. These Session variables are passed to the final page and calculations...
4
by: c676228 | last post by:
Hi all, In the second web form, I have the following code: (The peopleinfo is a user control which has name and ssn infomation, each field in this user control I have set enableviewstate=true). I...
3
by: steph_mw | last post by:
I have a web application and when a user opens the application (using windows integration) and loads some data, it loads a ID number into the session state. If for some reason they go away from...
3
by: Phillip N Rounds | last post by:
I'm writing a user control which has two states: Active & InActive. I additionally am required that there to be only one active control per page, and all logic has to be contained within the...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.