Kasuni Abegunawardana

Kasuni Abegunawardana

  • NA
  • 211
  • 124.9k

How to call a class into aspx.cs

Nov 22 2017 12:41 AM
Hi all this the class that what i have created. Plase i want it to call into my aspx.cs web form. How can i do that? I tried namespace.login; it dosen't work.
And i want to know how to call this class into the aspx.cs form.
 
Thank you. 
 
 
 
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Data;
using System.Linq;
using System.Web;
namespace Food_Calorie_Calculator__Final_Project.Account
{
public class Login
{
static string U_EmailAddress;
static string U_Password;
public string ID = string.Empty;
SqlConnection conn = Main.GetDBConnection();
public Login()
{ }
public Login(string _U_EmailAddress, string _U_Password)
{
U_EmailAddress = _U_EmailAddress;
U_Password = _U_Password;
}
public string getemailinfo
{
get
{
return U_EmailAddress;
}
}
public string getpassinfo
{
get
{
return U_Password;
}
}
public string Validation()
{
try
{
DataTable usertable = new DataTable();
string SQL = @"SELECT U_EmailAddress FROM User_tb where
U_EmailAddress ='" + U_EmailAddress + "' AND U_Password ='" + U_Password + "'";
SqlDataAdapter Userdataadapter = new SqlDataAdapter(SQL, conn);
Userdataadapter.Fill(usertable);
foreach (DataRow myrow in usertable.Rows)
{
ID = (myrow[0].ToString());
}
}
catch (InvalidCastException e)
{
throw (e); // Rethrowing exception e
}
return ID;
}
}
}

Answers (3)