C# Newbie Question
Hello and thanks for taking a moment to read this message. I am simply trying to create a variable at the top of the page (string site ="ggggggggg";) and later on use <%Response.Write(site);%> to display the variable on my page. For some reason VS 2003 keeps telling me my variable does not exhist. Can anyone give some advise as to what I should do. I am using Classic ASP style coding for this.
The variable is declared at the top of the page and then I try to display it where the table that says "This program is intended........" is at on the page. Below is my complete aspx page code. Major points of interest are in bold. If you have any suggestions I would be most appreciative. Thanks. - Jason
<%@ Page Language="c#" codebehind="login2.aspx.cs" autoeventwireup="false" Inherits="HNINEW.WebForm2" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<%
Get URL
string site ="ggggggggg";
//Create Title for WebPage
string title = "";
if (null != Request.Form["title"])
{
title = Request.Form["title"].ToString();
}
else if(null == Request.Form["title"])
{
if(null != Session["title"].ToString())
{
title = Session["title"].ToString();
}
}
Session["title"] = title;
if(null == Session["referrer"])
{
Session["referrer"] = Request.UrlReferrer.ToString();
}
//Get the CSS for the web page
string CSSFile = "";
if (null != Request.Form["CompanyID"])
{
CSSFile = "CompanyCSSImg/CSS/" + Request.Form["CompanyID"].ToString() + ".css";
Session["CompanyID"] = Request.Form["CompanyID"];
}
else if(null == Request.Form["CompanyID"])
{
if(null != Session["CompanyID"].ToString())
{
CSSFile = "CompanyCSSImg/CSS/" + Session["CompanyID"].ToString() + ".css";
}
}
if (null != Request.Form["CompanyGuid"])
{
Session["CompanyGuid"] = Request.Form["CompanyGuid"].ToString();
}
%>
<HEAD>
<title>
<%Response.Write(title);%>
- Demo</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<link href="<%Response.Write(CSSFile);%>" type="text/css" rel="stylesheet" >
<script language="javascript" type="text/javascript">
function goFirst()
{
frmLogin.txtUserName.focus();
}
function setBookmark()
{
var url = "<%Response.Write(Session["referrer"].ToString());%>";
var str = "<%Response.Write(Session["Title"].ToString() + " - Demo");%>";
if(str == '')
{
str = url;
}
if(document.all)window.external.AddFavorite(url,st r);
else alert('Press CTRL and D to add a bookmark to:\n"' + url + '".');
}
</script>
</HEAD>
<body onload="goFirst()" ms_positioning="GridLayout">
<form id="frmLogin" method="post" runat="server">
<table class="HeaderLogoTable" bordercolor="yellow" cellspacing="0" cellpadding="0" width="100%"
border="0">
<tbody>
<tr valign="top" height="74">
<%
string imgLogo = "";
if (null != Request.Form["CompanyID"])
{
imgLogo = "CompanyCSSImg/" + Request.Form["CompanyID"].ToString() + "/logo.gif";
}
else if (null == Request.Form["CompanyID"])
{
if(null != Session["CompanyID"].ToString())
{
imgLogo = "CompanyCSSImg/" + Session["CompanyID"].ToString() + "/logo.gif";
}
}
%>
<td align="right">
<img alt="" src="<%Response.Write(imgLogo);%>" border="0" ></td>
</tr>
</tbody>
</table>
<table class="HeaderMenuTable" height="15" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr valign="top">
<td nowrap>
</td>
</tr>
</tbody>
</table>
<table height="79%" width="100%" border="0">
<tbody>
<tr>
<td class="mycorpclass" align="center">
Corporate Purchasing Program</td>
<td>
<br>
</td>
</tr>
<tr>
<td align="center">
<table width="50%" border="0">
<tbody>
<tr>
<td class="whitetext">
This program <%Response.Write(site);%>is intended for dealer principals and dealership administrators to assist in the efficient operation of their business. Utilizing these programs for a personal nature is prohibited.</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td align="center">
<table class="body" height="100%" width="50%" border="0">
<tbody>
<tr>
<td class="TableTD">
<asp:Label id="loginError" runat="server" forecolor="red" text=" "></asp:Label></td>
</tr>
<tr>
<td class="whitetext" align="center" height="5%">
Please Login:</td>
</tr>
<tr>
<td valign="top" align="center">
<table class="TableTD" width="100%">
<tbody>
<tr>
<td class="whitetext">
Customer Number:</td>
<td>
<asp:TextBox id="txtPassword" Runat="server" Width="150px" TextMode="Password"></asp:TextBox>
</td>
</tr>
<tr>
<td class="whitetext">
Zip:</td>
<td>
<asp:TextBox id="txtZip" Runat="server" Width="150px" MaxLength="6"></asp:TextBox>
</td>
</tr>
<tr>
<td class="HeaderLogoTable" align="center" colspan="2">
<input id="Login" type="submit" value="Login" name="Login" runat="server" onserverclick="Login_Click"></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td align="center" width="100%">
<a href="javascript:setBookmark();"><b>Click here to Bookmark this Page</b></a></td>
</tr>
</tbody>
</table>
<table class="Footer" height="5%" width="100%">
<tbody>
<tr>
<td></td>
</tr>
<tr>
<td align="right">
* Technical Assistance -Helpdesk contact information for site assistance email <a href="mailto:tmrhelpdesk@themailroom.com">
tmrhelpdesk@themailroom.com.</a></td>
</tr>
</tbody>
</table>
</form>
</body>
</HTML>
|