Need help on ASP.NET (Login Page)

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Nov 2009
Posts: 1
Reputation: Kristysos is an unknown quantity at this point 
Solved Threads: 0
Kristysos Kristysos is offline Offline
Newbie Poster

Need help on ASP.NET (Login Page)

 
0
  #1
Nov 2nd, 2009
I don't know why it kept appear this error: The name 'LogoutBT' does not exist in the current context.

All my textboxes and buttons do not exist in the current context

Please help me. Thanks.



using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;



public partial class _Default : System.Web.UI.Page
{
DBConnect Connect = new DBConnect();
protected void Page_Load(object sender, EventArgs e)
{

if ((string)Session["sFlag"] == "T")

{

LoggedIn();


}
else
{
Session["sName"] = null;
Session["sUserName"] = null;
Session["sAddress"] = null;
Session["sCoContact"] = null;
Session["sPIC"] = null;
Session["sPICContact"] = null;
Session["sFlag"] = "F";
passwordTB.Visible = true;
passwordTB.Text = "";
usernameTB.Visible = true;
usernameTB.Text = "";
usernameTB.Text = "UserID:";
LogoutBT.Visible = false;
LoginBT.Visible = true;


}
}



protected void LoginBT_Click(object sender, EventArgs e)
{
if (usernameTB.Text != "")
{
if (passwordTB.Text != "")
{
OleDbConnection mdb = new OleDbConnection();
OleDbCommand cmd;
OleDbDataReader rdr;
Connect.DBConnection(mdb);
mdb.Open();
string SQLinfo = "SELECT * FROM Customers WHERE cUserName = '" +
usernameTB.Text.ToUpper() + "'";
string SQLlog = "INSERT INTO Log (lName,lLogIn) " +
"VALUES (@UserName, @Date)";
cmd = new OleDbCommand(SQLinfo, mdb);
rdr = cmd.ExecuteReader();
while (rdr.Read())
{
if (passwordTB.Text == (string)rdr["cPassword"])
{
Session["sName"] = rdr["cName"];
Session["sUserName"] = rdr["cUserName"];
Session["sAddress"] = rdr["cCoAddress"];
Session["sCoContact"] = rdr["cCoContact"];
Session["sPIC"] = rdr["cPersonInCharge"];
Session["sPICContact"] = rdr["cPICContact"];
Session["sEmail"] = rdr["cEmail"];
Session["sStatus"] = rdr["cStatus"];
Session["sFlag"] = "T";
rdr.Close();
cmd = new OleDbCommand(SQLlog, mdb);
cmd.Parameters.Add("@UserName", OleDbType.Char).Value = (string)Session["sCoName"];
cmd.Parameters.Add("@Date", OleDbType.Date).Value = DateTime.Now;
cmd.ExecuteNonQuery();
mdb.Close();
LoggedIn();
break;
}
else
{
rdr.Close();
mdb.Close();
usernameTB.Text = "";
passwordTB.Text = "";
Response.Write("<script>alert('Error signing in')</script>");
break;
}
}
mdb.Close();
}
else
{
passwordTB.Focus();
Response.Write("<script>alert('Please enter your password')</script>");
}
}
else
{
usernameTB.Focus();
Response.Write("<script>alert('Please enter your UserID')</script>");
}
}

protected void LogoutBT_Click(object sender, EventArgs e)
{
OleDbConnection mdb = new OleDbConnection();
OleDbCommand cmd;
Connect.DBConnection(mdb);
string SQLlog = "UPDATE Log SET lLogOut = @Date WHERE lCoName = @Name";
cmd = new OleDbCommand(SQLlog, mdb);
cmd.Parameters.Add("@Date", OleDbType.Date).Value = DateTime.Now;
cmd.Parameters.Add("@Name", OleDbType.Char).Value = (string)Session["sUserName"];
mdb.Open();
cmd.ExecuteNonQuery();
mdb.Close();
LoggedOut();
}
protected void LoggedOut()
{
Session["sName"] = null;
Session["sUserName"] = null;
Session["sAddress"] = null;
Session["sCoContact"] = null;
Session["sPIC"] = null;
Session["sPICContact"] = null;
Session["sFlag"] = "F";
passwordTB.Visible = true;
passwordTB.Text = "";
usernameTB.Visible = true;
usernameTB.Text = "";
usernameTB.Text = "UserID:";
LogoutBT.Visible = false;
LoginBT.Visible = true;
Response.Redirect("OnlineRVform.aspx");
}
protected void LoggedIn()
{
passwordTB.Visible = false;
passwordTB.Text = "";
usernameTB.Visible = false;
usernameTB.Text = "";
usernameTB.Text = (string)Session["sPIC"];
LogoutBT.Visible = true;
LoginBT.Visible = false;

}
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 225
Reputation: mail2saion is an unknown quantity at this point 
Solved Threads: 34
mail2saion's Avatar
mail2saion mail2saion is offline Offline
Posting Whiz in Training
 
0
  #2
Nov 3rd, 2009
Check that controls were placed inside form tag of your html markup page.
MARK AS SOLVED if its help you.

REGARDS
MCTS - Shawpnendu bikash maloroy
http://shawpnendu.blogspot.com
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 6
Reputation: mailme.vibin is an unknown quantity at this point 
Solved Threads: 1
mailme.vibin mailme.vibin is offline Offline
Newbie Poster
 
0
  #3
Nov 3rd, 2009
if u r using a content place holder...in 2008 .net u need to refer that first then the button..may be this wil help
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



Tag cloud for ASP.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC