Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

Namespace


  • Please log in to reply

#1
GinaB

GinaB

    New Member

  • Member
  • Pip
  • 7 posts
I am trying to understand namespaceing... I was trained in Java but the company I work for uses C#... Can someone shed some light for me please..

Below is code for a login... But I keep getting errors on the namespacing...

asp code:
<%@ Page Language="C#" MasterPageFile="~/MasterPage3.master" AutoEventWireup="true" CodeFile="Login.aspx.cs" Inherits="Edcc" Title="SignOn" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder2" runat="Server">
<form action="Login.aspx" method="post" runat="server">
<p align="center" style=font-size:xx-large>
East Divisional Call Center</p>
<p align="center">
<asp:Label ID="Message" runat="server"></asp:Label>
</p>
<h3 align="center">Login Form</h3>
<div align="center">
Login:<asp:TextBox ID="txtLogin" Width="200" runat="server" />
<asp:RequiredFieldValidator ControlToValidate="txtLogin" Display="Static" Font-Names="Verdana, arial, sans-serif"
ForeColor="red" Font-Size="9pt" ErrorMessage="Incorrect UserId Entered." runat="server"
ID="RFVLogin" />
<p>
Password:<asp:TextBox ID="txtPassword" Width="200" runat="server" TextMode="Password" />
<asp:RequiredFieldValidator ControlToValidate="txtPassword" Display="Static" Font-Names="Verdana, arial, sans-serif"
ForeColor="red" Font-Size="9pt" ErrorMessage="Incorrect Password Entered." runat="server"
ID="RFVPassword"></asp:RequiredFieldValidator>
</div>

<div align="center" >
<asp:Button ID="btnSignIn" runat="server" Text="Sign In" OnClick="btnSignIn_Click" Width="64px" />
</div>

</form>

</asp:Content>


Code Behind:

using System;
using System.Data;
using System.Data.Sql;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.SessionState;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;


public class Login : System.Web.UI.Page
{
public System.Web.UI.WebControls.Label Message;
public System.Web.UI.HtmlControls.HtmlTable tblSignIn;
public System.Web.UI.WebControls.TextBox txtLogin;
public System.Web.UI.WebControls.RequiredFieldValidator RFVLogin;
public System.Web.UI.WebControls.TextBox txtPassword;
public System.Web.UI.WebControls.RequiredFieldValidator RFVPassword;
public System.Web.UI.WebControls.Button btnSignIn;

protected void Page_Load(object sender, EventArgs e)
{

if ( !IsPostBack )
{
//Display welcome message
Message.Text = "Enter your login and password.";
}
}
protected void btnSignIn_Click(Object obj, EventArgs e)
{
if(Page.IsValid)
{
//Check username/password against Emp_DB_Employee database
SQLConnection conn = new
SQLConnection("server=localhost;uid=sa;pwd=;database=Login");

//get row back based on username/password
string strsql = "Select * from Emp_DB_Employee where Id='" +
txtLogin.Text + "' and Password = '" +
txtPassword.Text + "'";

SQLDataSetCommand dsc = new SQLDataSetCommand(strsql, conn);

//populate a dataset with SQL results
DataSet ds = new DataSet ();
dsc.FillDataSet(ds, "Emp_DB_Employee" );

//check to see if the dataset contains no rows (if it is EOF) user is invalid
if(ds.Tables ["Emp_DB_Employee"].Rows.Count ==0)
{
Message.Text = "Invalid User Name and Password. Try Again.";
}else{
Message.Text = "Congratulations, " + txtLogin.Text +
"!!! You have successfully signed in.";
}
}
}
}


this is the error I keep getting??????

Error 4 Make sure that the class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class (e.g. Page or UserControl). C:\_Programming\Website Testing\Gina WebSite\Login.aspx.cs 1 33 C:\...\Gina WebSite\


Thank you for any help you can give

Gina
  • 0

Advertisements


#2
StephenL

StephenL

    Member

  • Member
  • PipPip
  • 12 posts
what makes you think this is a namespace problem? (just to clarify)
  • 0

#3
GinaB

GinaB

    New Member

  • Topic Starter
  • Member
  • Pip
  • 7 posts
Hi Stephen,

Thank you for your response... But I figured out what I was missing...

it was in the inherit part on the ASPX page :whistling:
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP