1 Replies - 1686 Views - Last Post: 17 June 2014 - 01:06 PM Rate Topic: -----

#1 Welendowd  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 28
  • Joined: 27-March 12

error CS0103: VS 2012 Senior Project

Posted 17 June 2014 - 12:43 PM

Hey guys I am stomped. I have been trying to get my senior project up and running however I keep getting errors. I don't understand what I am doing wrong. This is a senior project and I am in a group with four other people, one of the team members posted a update to the code in our college shell. He said it runs perfect with no errors. I made sure I reset the databvse connection string in the we.config file. I am getting the error code CS0103: The name 'txtShippingSameAsBilling' does not exist in the current context.

I have looked and the ID's are the same. The only thing I can think of is the way the pages are related to each other somehow. Whenever I first opened the project, all the 'frms' has this as the class declaration: public partial class frmMain : System.Web.UI.Page

I changed them so that the each frm had it's own name because I was getting errors saying the page_load function has already defined in 'frmMain'. I changed them to their own names with got rid of those errors, however, it gave me those CS0103 errrors on just about all of my pages. I will include the code for one of my pages and the errors on that page.

using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class frmRegister : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //If user is logged in then they need to see Log Out and not see Register
        if (Session["SecurityLevel"] == "A")
        {
            imgbtnLogin.Visible = false;
            imgbtnLogOut.Visible = true;
            imgbtnRegister.Visible = false;
            imgbtnNoRegister.Visible = true;
            imgbtnAccount.Visible = true;
            imgbtnNoAccount.Visible = false;
            imgbtnOrders.Visible = true;
            imgbtnCart.Visible = false;
           
        }
        else if (Session["SecurityLevel"] == "U")
        {
            imgbtnLogin.Visible = false;
            imgbtnLogOut.Visible = true;
            imgbtnRegister.Visible = false;
            imgbtnNoRegister.Visible = true;
            imgbtnAccount.Visible = true;
            imgbtnNoAccount.Visible = false;
            imgbtnOrders.Visible = false;
            imgbtnCart.Visible = true;
            Panel2.Visible = false;
        }
        else //If user is not logged in they need to see Login and Register
        {
            imgbtnLogin.Visible = true;
            imgbtnLogOut.Visible = false;
            imgbtnRegister.Visible = true;
            imgbtnNoRegister.Visible = false;
            imgbtnAccount.Visible = false;
            imgbtnNoAccount.Visible = true;
            imgbtnOrders.Visible = false;
            imgbtnCart.Visible = true;
            Panel2.Visible = false;
        }
    }

    protected void Button2_Click1(object sender, EventArgs e)
    {

    }
    protected void btnContinue_Click(object sender, EventArgs e)
    {
        //sets session state for information submitted by user in panel1
        Session["UserName"] = txtUserName.Text;

        Session["UserPassword"] = txtUserPassword.Text;
        Session["Email"] = txtEmail.Text;
        Session["SecurityLevel"] = "U";
        Session["MembershipDate"] = DateTime.Today;

        //Checks if Username already exsits and if it does, displays error message. If not, continues with registration on panel2.
       
        if (WSC.clsRegisterCustomer.CheckUsername(Server.MapPath("WSC_DB.mdb"), Session["UserName"].ToString()) == false)
        {
            Label1.Text = "Username already exsists. Please select a different username.";
        }
        else
        {
            Panel1.Visible = false;
            Panel2.Visible = true;
        }
    }

    protected void btnCreateAccount_Click(object sender, EventArgs e)
    {
        //sets session state for information submitted by user from panel2
        Session["TelephoneNumber"] = txtTelephoneNumber.Text;
        Session["FirstName"] = txtFirstName.Text;
        Session["MiddleName"] = txtMiddleName.Text;
        Session["LastName"] = txtLastName.Text;
        Session["Street1"] = txtStreet1.Text;
        Session["Street2"] = txtStreet2.Text;
        Session["City"] = txtCity.Text;
        Session["State"] = txtState.Text;
        Session["Zip"] = txtZipCode.Text;
        Session["ShippingSameAsBilling"] = txtShippingSameAsBilling.Text;

        
        //inserts user information into the database table (tblPatronMaster).
       if (WSC.clsRegisterCustomer.SaveCustomer(Server.MapPath("WSC_DB.mdb"),

                     Session["UserName"].ToString(),
                     Session["UserPassword"].ToString(),
                     Session["SecurityLevel"].ToString(),
                     Session["ShippingSameAsBilling"].ToString(),
                     Session["MembershipDate"].ToString(),
                     Session["Zip"].ToString(),
                     Session["TelephoneNumber"].ToString(),
                     Session["FirstName"].ToString(),
                     Session["MiddleName"].ToString(),
                     Session["LastName"].ToString(),
                     Session["Email"].ToString(),
                     Session["City"].ToString(),
                     Session["Street1"].ToString(),
                     Session["Street2"].ToString(),
                     Session["State"].ToString()))
                {
                    Response.Redirect("frmLogin.aspx");
                }
                {
                    //Display error message
                }
            }

    
   
    protected void btnCancel_Click(object sender, EventArgs e)
    {

    }
}



Errors:

frmRegister.aspx.cs(14,13,14,44): warning CS0252: Possible unintended reference comparison; to get a value comparison, cast the left hand side to type 'string'
: error CS0103: The name 'imgbtnLogin' does not exist in the current context
: error CS0103: The name 'imgbtnLogOut' does not exist in the current context
: error CS0103: The name 'imgbtnRegister' does not exist in the current context
: error CS0103: The name 'imgbtnNoRegister' does not exist in the current context
: error CS0103: The name 'imgbtnAccount' does not exist in the current context
: error CS0103: The name 'imgbtnNoAccount' does not exist in the current context
: error CS0103: The name 'imgbtnOrders' does not exist in the current context
: error CS0103: The name 'imgbtnCart' does not exist in the current context
: warning CS0252: Possible unintended reference comparison; to get a value comparison, cast the left hand side to type 'string'
: error CS0103: The name 'imgbtnLogin' does not exist in the current context
: error CS0103: The name 'imgbtnLogOut' does not exist in the current context
: error CS0103: The name 'imgbtnRegister' does not exist in the current context
: error CS0103: The name 'imgbtnNoRegister' does not exist in the current context
: error CS0103: The name 'imgbtnAccount' does not exist in the current context
: error CS0103: The name 'imgbtnNoAccount' does not exist in the current context
: error CS0103: The name 'imgbtnOrders' does not exist in the current context
: error CS0103: The name 'imgbtnCart' does not exist in the current context
: error CS0103: The name 'Panel2' does not exist in the current context
: error CS0103: The name 'imgbtnLogin' does not exist in the current context
: error CS0103: The name 'imgbtnLogOut' does not exist in the current context
: error CS0103: The name 'imgbtnRegister' does not exist in the current context
: error CS0103: The name 'imgbtnNoRegister' does not exist in the current context
: error CS0103: The name 'imgbtnAccount' does not exist in the current context
: error CS0103: The name 'imgbtnNoAccount' does not exist in the current context
: error CS0103: The name 'imgbtnOrders' does not exist in the current context
: error CS0103: The name 'imgbtnCart' does not exist in the current context
: error CS0103: The name 'Panel2' does not exist in the current context
: error CS0103: The name 'txtUserName' does not exist in the current context
: error CS0103: The name 'txtUserPassword' does not exist in the current context
: error CS0103: The name 'txtEmail' does not exist in the current context
: error CS0103: The name 'Label1' does not exist in the current context
: error CS0103: The name 'Panel1' does not exist in the current context
: error CS0103: The name 'Panel2' does not exist in the current context
: error CS0103: The name 'txtTelephoneNumber' does not exist in the current context
: error CS0103: The name 'txtFirstName' does not exist in the current context
: error CS0103: The name 'txtMiddleName' does not exist in the current context
: error CS0103: The name 'txtLastName' does not exist in the current context
: error CS0103: The name 'txtStreet1' does not exist in the current context
: error CS0103: The name 'txtStreet2' does not exist in the current context
: error CS0103: The name 'txtCity' does not exist in the current context
: error CS0103: The name 'txtState' does not exist in the current context
: error CS0103: The name 'txtZipCode' does not exist in the current context
: error CS0103: The name 'txtShippingSameAsBilling' does not exist in the current context


and here is the the .aspx code file:


Page Language="C#" AutoEventWireup="true" CodeFile="frmRegister.aspx.cs" Inherits="frmRegister" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        .auto-style3 {
            height: 392px;
            width: 548px;
        }
        .auto-style6 {
            text-align: left;
            width: 266px;
            height: 39px;
        }
        .auto-style7 {
            height: 39px;
            text-align: left;
            width: 481px;
        }
        .auto-style12 {
            height: 22px;
        }
        .auto-style19 {
            text-align: left;
            width: 481px;
            height: 38px;
        }
        .auto-style20 {
            text-align: left;
            width: 481px;
            height: 28px;
        }
        .auto-style24 {
            height: 1867px;
        }
        .auto-style26 {
            height: 386px;
        }
        .auto-style27 {
            text-align: left;
            width: 266px;
            height: 38px;
        }
        .auto-style28 {
            text-align: left;
            width: 266px;
            height: 28px;
        }
        .auto-style29 {
            height: 107px;
            width: 548px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div style="text-align: center">
    
        <asp:Image ID="Image1" runat="server" 
            ImageUrl="~/images/WSC.jpg" Height="106px" Width="1511px" />
    </div>
    <table border="0" cellspacing="0" cellpadding="0" align="center">       <!-- Header area of website start-->
    <tr>

    <td><asp:ImageButton ID="ImageButton1" runat="server" Height="58px" 
        ImageUrl="~/images/home.png" Width="160px" PostBackUrl="~/frmMain.aspx" /></td> <!-- home button -->
    <td><asp:ImageButton ID="ImageButton2" runat="server" Height="58px" 
        ImageUrl="~/images/catalog.png" Width="180px" PostBackUrl="~/frmCatalog.aspx" /></td><!-- catalog button -->
    <td><asp:ImageButton ID="imgbtnLogin" runat="server" Height="58px" 
        ImageUrl="~/images/Login.png" Width="162px" PostBackUrl="~/frmLogin.aspx" /><!-- login button -->
        <asp:ImageButton ID="imgbtnLogOut" runat="server" Height="58px" 
        ImageUrl="~/images/LogOut.png" Width="162px" /><!-- logout button -->
    </td>
    <td><asp:ImageButton ID="imgbtnAccount" runat="server" Height="58px" 
        ImageUrl="~/images/Account.png" Width="152px" PostBackUrl="~/frmAccount.aspx" /><!-- Account button -->
        <asp:ImageButton ID="imgbtnNoAccount" runat="server" Height="58px" 
        ImageUrl="~/images/Cover.png" Width="152px" Visible="False" /><!-- Cover Account button -->
    </td>
    <td><asp:ImageButton ID="imgbtnRegister" runat="server" Height="58px" 
        ImageUrl="~/images/register.png" Width="152px" PostBackUrl="~/frmRegister.aspx" /> <!-- Register button -->
        <asp:ImageButton ID="imgbtnNoRegister" runat="server" Height="58px" 
        ImageUrl="~/images/Cover.png" Width="152px" PostBackUrl="" /> <!-- Cover Register button -->
    </td>
    <td><asp:ImageButton ID="ImageButton6" runat="server" Height="58px" 
        ImageUrl="~/images/redbar2.png" Width="593px" /></td> <!-- red bar -->
    <td><asp:ImageButton ID="imgbtnCart" runat="server" Height="58px" 
        ImageUrl="~/images/Cart.png" Width="160px" PostBackUrl="frmCart.aspx"/><!-- shopping cart button -->
        <asp:ImageButton ID="imgbtnOrders" runat="server" Height="58px" 
        ImageUrl="~/images/Orders.png" Width="160px" PostBackUrl="frmOrders.aspx"/><!-- Orders page button -->
    </td> 

    <table border="0" cellspacing="0" cellpadding="0" align="center">       <!-- Header area of website end-->
    </tr>                                                                   
    </table>
    
    <div align="center" class="auto-style24">                                                    <!-- Body area of website start-->
            <br />
            <br />
        <asp:Panel ID="Panel1" runat="server" Height="369px">
            <div class="auto-style26">
                <table class="auto-style29" style="font-family:Verdana;font-size:100%;">
                    <tr>
                        <td align="center" class="auto-style12" colspan="2" style="color:White;background-color:#5D7B9D;font-weight:bold;">Sign Up for Your New Account</td>
                    </tr>
                    <tr>
                        <td class="auto-style6">
                            <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="txtUserName">User Name:</asp:Label>
                        </td>
                        <td class="auto-style7">
                            <asp:TextBox ID="txtUserName" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="auto-style27">
                            <asp:Label ID="PasswordLabel0" runat="server" AssociatedControlID="txtUserPassword">Password:</asp:Label>
                        </td>
                        <td class="auto-style19">
                            <asp:TextBox ID="txtUserPassword" runat="server" TextMode="Password" Width="149px">></asp:TextBox> 
                        </td>
                    </tr>
                    <tr>
                        <td class="auto-style28">
                            <asp:Label ID="ConfirmPasswordLabel0" runat="server" AssociatedControlID="txtConfirmPassword">Confirm Password:</asp:Label>
                        </td>
                        <td class="auto-style20">
                            <asp:TextBox ID="txtConfirmPassword" runat="server" TextMode="Password" Width="149px"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="auto-style28">
                            <asp:Label ID="EmailLabel0" runat="server" AssociatedControlID="txtEmail">E-mail:</asp:Label>
                        </td>
                        <td class="auto-style20">
                            <asp:TextBox ID="txtEmail" runat="server" Width="149px"></asp:TextBox>
                        </td>
                    </tr>
                </table>
                <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="txtConfirmPassword" ControlToValidate="txtUserPassword" ErrorMessage="Passwords must match!" ForeColor="#CC3300"></asp:CompareValidator>
                <br />
                <asp:Label ID="Label1" runat="server" ForeColor="#CC3300"></asp:Label>
                <br />
                <asp:Button ID="btnContinue" runat="server" onclick="btnContinue_Click" Text="Continue" />
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <asp:Button ID="btnCancel1" runat="server" Text="Cancel" CausesValidation="False" PostBackUrl="~/frmMain.aspx" />
                <br />
                <br />
                <br />
                
                <br />
            </div>
        </asp:Panel>
        <asp:Panel ID="Panel2" runat="server" Height="565px">
                    <br />
                    <table class="auto-style3" style="font-family:Verdana;font-size:100%;">
                        <tr>
                            <td align="center" class="auto-style12" colspan="2" style="color:White;background-color:#5D7B9D;font-weight:bold;">Sign Up for Your New Account</td>
                        </tr>
                        <tr>
                            <td class="auto-style27">First Name</td>
                            <td class="auto-style19">
                                <asp:TextBox ID="txtFirstName" runat="server"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td class="auto-style27">Middle Name:</td>
                            <td class="auto-style19">
                                <asp:TextBox ID="txtMiddleName" runat="server"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td class="auto-style27">Last Name:</td>
                            <td class="auto-style19">
                                <asp:TextBox ID="txtLastName" runat="server"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td class="auto-style27">Telephone Number:</td>
                            <td class="auto-style19">
                                <asp:TextBox ID="txtTelephoneNumber" runat="server"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td class="auto-style27">Street Address:</td>
                            <td class="auto-style19">
                                <asp:TextBox ID="txtStreet1" runat="server"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td class="auto-style27">Street Address (Cont):</td>
                            <td class="auto-style19">
                                <asp:TextBox ID="txtStreet2" runat="server"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td class="auto-style27">City:</td>
                            <td class="auto-style19">
                                <asp:TextBox ID="txtCity" runat="server"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td class="auto-style27">State:</td>
                            <td class="auto-style19">
                                <asp:TextBox ID="txtState" runat="server"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td class="auto-style27">Zip Code:</td>
                            <td class="auto-style19">
                                <asp:TextBox ID="txtZipCode" runat="server"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td class="auto-style27">Shiiping Same As Billing:</td>
                            <td class="auto-style19">
                                <asp:TextBox ID="txtShippingSameAsBilling" runat="server"></asp:TextBox>
                            </td>
                        </tr>
                    </table>
                    <br />
                    <asp:Button ID="btnCreateAccount" runat="server" Text="CreateAccount" onclick="btnCreateAccount_Click" />
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:Button ID="btnCancel" runat="server" Text="Cancel" CausesValidation="False" PostBackUrl="~/frmMain.aspx" />
                    <br />
                </asp:Panel>
        </div>
    </form>
</body>
</html>



I mean it's all right there on the page.

Before I changed the class name(when they were all 'frmMain') all the buttons, etc... all worked. How is the project working for my team and not me?

Is This A Good Question/Topic? 0
  • +

Replies To: error CS0103: VS 2012 Senior Project

#2 andrewsw  Icon User is online

  • It's just been revoked!
  • member icon

Reputation: 3624
  • View blog
  • Posts: 12,536
  • Joined: 12-December 12

Re: error CS0103: VS 2012 Senior Project

Posted 17 June 2014 - 01:06 PM

Someone may suggest a specific place to look but, if you rename the main window, then ensure that it is renamed everywhere. Check the Project Properties; you can use Find in Files but you may have to open some config files separately (I am not always convinced that it searches these files).

Note that I don't use ASP but this advice applies to any project-type.

This post has been edited by andrewsw: 17 June 2014 - 01:07 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1