Session Variables not available in UserControl

L

Lee Moore

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

Lee Moore

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_id")%>"><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>
 
L

Lee Moore

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

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,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top