I'm working on my company's website. The task I am assigned is to display the user's name and ID at the top of each page of the website, once the user logs in. However, the top section of each page is controlled by an Include file, Header.inc. I'm getting the examinee's name and ID through some Javascript. The problem is that an aspx page inserts the Include file before it runs the javascript (if you're not familiar with what I'm talking about, see here, towards the bottom of the page: http://www.w3schools.com/asp/asp_incfiles.asp). Basically, the code in the Include file references the variables for the name and ID before the script declares them. I really don't want to get rid of the Include file. Any ideas how I can get around this problem?
Thanks in advance,
Dan
Here's the error I get on the webpage:
Server Error in '/' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30451: Name 'strName' is not declared.
Source Error:
Line 11: </br>Line 12: </br>Line 13: <a><%=strName%> </a>Line 14: </br>Line 15: <a>Examinee ID# <%=strNBCEID%> </a>
|
Here's the code for the Include file:
<!-- Start Header -->
<div class="container-header">
<div class="pageheader">
<a href="/home.aspx" > (text removed) Home</a> |
<a href="(link removed)" >(text removed)</a> |
<a href="/logout.aspx" >Logout</a> |
<a href="/contact.aspx" >Contact Us</a>
</br>
</br>
</br>
</br>
<a><%=strName%> </a>
</br>
<a>Examinee ID# <%=strNBCEID%> </a>
</div>
<div class="header">
<br />
<span id="menuiconspan">
<a onclick="showMenu()">
<img src="/images/menubutton.png" />
</a>
</span>
<span id="headermenulogospan-lg" >
<img src="/images/logow.png" height="73px" width="187.5" />
</span>
<span id="headermenulogospan-sm">
<img src="/images/logow.png" height="49px" width="125" />
</span>
</div>
</div>
<!-- End Header -->
Here's some of the code (the section I deemed relevant) of my aspx file:
<%@ Page Language="VB" Inherits="MySecurity" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Dim strName As String
Dim strAddress As String
Dim strPhone As String
Dim strEmailProc as String
dim strNBCEID as String
Protected Sub Page_Load()
Dim dvUser As Data.DataView
SecurityCheck()
sqlUser.SelectParameters("ExamineeNo").DefaultValue = Session("ExamineeNo")
dvUser = sqlUser.Select(DataSourceSelectArguments.Empty)
strName = dvUser.Table.Rows(0)("FirstName").ToString & " " & dvUser.Table.Rows(0)("LastName").ToString & " " & dvUser.Table.Rows(0)("Suffix").ToString
If dvUser.Table.Rows(0)("CurrentCountry").ToString = "1" Then
strAddress = dvUser.Table.Rows(0)("CurrentStreet").ToString & "<br />" & dvUser.Table.Rows(0)("CurrentCity").ToString & ", " & dvUser.Table.Rows(0)("CurrentState").ToString & " " & dvUser.Table.Rows(0)("CurrentZip").ToString
Else
strAddress = dvUser.Table.Rows(0)("CurrentStreet").ToString & "<br />" & dvUser.Table.Rows(0)("CurrentCity").ToString & " " & ZipFormat(dvUser.Table.Rows(0)("CurrentCountry").ToString, dvUser.Table.Rows(0)("CurrentZip").ToString) & "<br/>" & GetTableValueString("lkpCountry", "CountryName", "[CountryID]=" & dvUser.Table.Rows(0)("CurrentCountry").ToString)
End If
If dvUser.Table.Rows(0)("CurrentPhone").ToString <> "" Then
strPhone = Left(dvUser.Table.Rows(0)("CurrentPhone").ToString, 3) & "-" & Mid(dvUser.Table.Rows(0)("CurrentPhone").ToString, 4, 3) & "-" & Right(dvUser.Table.Rows(0)("CurrentPhone").ToString, 4)
Else
strPhone = ""
End If
strEmailProc = dvUser.Table.Rows(0)("Email").ToString
strNBCEID = dvUser.Table.Rows(0)("NBCEID").ToString
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>(text removed)</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/javascript" src="../js/template.js"></script>
<link href="../css/template.css" rel="stylesheet" />
<script language="javascript" type="text/javascript">
function PageLoad() {
}
</script>
<script type="text/javascript" src="../js/jquery-1.js"></script>
<script type="text/javascript" src="../js/jquery.js"></script>
</head>
<body onload="PageLoad()" onresize="resetMenu();">
<form id="form1" runat="server" requiressl="true">
<div>
<!-- #include virtual="~/include/sidenav.inc" -->
<!-- #include virtual="~/include/header.inc" -->
<div class="container">
<!-- #include virtual="~/include/leftcolumn.inc" -->
Thanks again