Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old May 21st, 2006, 11:42 AM
Authorized User
Points: 239, Level: 4
Points: 239, Level: 4 Points: 239, Level: 4 Points: 239, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2005
Location: , , .
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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>
       &nbsp;</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="&nbsp;"></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>


  #2 (permalink)  
Old May 25th, 2006, 10:18 PM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

First you have to get out of the habit of classic ASP coding. You are defeating all the advantages of .NET programming. I know it can be difficult to break old habits, but you will be better off in the long run.



Similar Threads
Thread Thread Starter Forum Replies Last Post
newbie question pbb Ajax 0 September 26th, 2006 05:47 AM
Newbie question savoym JSP Basics 1 August 16th, 2006 03:15 AM
Newbie Question - Sorry! KP Crystal Reports 1 June 13th, 2006 02:45 AM
newbie question Warbird XML 0 May 11th, 2005 08:41 AM
Newbie question maccer88 Access 1 October 18th, 2003 05:53 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.