Hai All,
Im doing a login page.... And that was without cookie....
I realy dono how to create cookie...
pls anyone can help...
Here is code from Default.aspx for login control:
[HTML]<asp:Login ID="Login1" runat="server" BackColor="#F7F 6F3" BorderColor="#E 6E2D8"
BorderPadding=" 4" BorderStyle="So lid" BorderWidth="1p x" Font-Names="Verdana"
Font-Size="0.8em" ForeColor="#333 333" onauthenticate= "Login1_Authent icate"
CreateUserText= "Create User" CreateUserUrl=" ~/UserControl/AddStaff.ascx"
Height="162px" Width="292px">
<TextBoxStyle Font-Size="0.8em" />
<LoginButtonSty le BackColor="#FFF BFF" BorderColor="#C CCCCC" BorderStyle="So lid"
BorderWidth="1p x" Font-Names="Verdana" Font-Size="0.8em" ForeColor="#284 775" />
<InstructionTex tStyle Font-Italic="True" ForeColor="Blac k" />
<TitleTextSty le BackColor="#5D7 B9D" Font-Bold="True" Font-Size="0.9em"
ForeColor="Whit e" />
</asp:Login>[/HTML]
And here is the code behind.... Default.aspx.cs
[HTML]using System;
using System.Collecti ons;
using System.Configur ation;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Secu rity;
using System.Web.UI;
using System.Web.UI.H tmlControls;
using System.Web.UI.W ebControls;
using System.Web.UI.W ebControls.WebP arts;
using System.Xml.Linq ;
using System.Data.Sql Client;
public partial class test : System.Web.UI.P age
{
protected void Page_Load(objec t sender, EventArgs e)
{
}
protected void Login1_Authenti cate(object sender, AuthenticateEve ntArgs e)
{
bool Authenticated = false;
Authenticated = SiteLevelCustom AuthenticationM ethod(Login1.Us erName, Login1.Password );
e.Authenticated = Authenticated;
if (Authenticated == true)
{
Response.Redire ct("Dashboard2. aspx");
}
}
private bool SiteLevelCustom AuthenticationM ethod(string UserName, string Password)
{
bool boolReturnValue = false;
// Insert code that implements a site-specific custom
// authentication method here.
// This example implementation always returns false.
System.Data.Sql Client.SqlConne ction conn = new SqlConnection(" Data Source=(local); Initial Catalog=DBhelpd esk; Integrated Security=SSPI;" );
conn.Open();
System.Data.Sql Client.SqlComma nd comm = new SqlCommand("sp_ ValidateUser", conn);
comm.Parameters .AddWithValue(" @UserName", UserName);
comm.Parameters .AddWithValue(" @Password", Password);
comm.CommandTyp e = CommandType.Sto redProcedure;
SqlDataReader Dr;
Dr = comm.ExecuteRea der();
while (Dr.Read())
{
boolReturnValue = true;
}
Dr.Close();
return boolReturnValue ;
}
}[/HTML]
Im doing a login page.... And that was without cookie....
I realy dono how to create cookie...
pls anyone can help...
Here is code from Default.aspx for login control:
[HTML]<asp:Login ID="Login1" runat="server" BackColor="#F7F 6F3" BorderColor="#E 6E2D8"
BorderPadding=" 4" BorderStyle="So lid" BorderWidth="1p x" Font-Names="Verdana"
Font-Size="0.8em" ForeColor="#333 333" onauthenticate= "Login1_Authent icate"
CreateUserText= "Create User" CreateUserUrl=" ~/UserControl/AddStaff.ascx"
Height="162px" Width="292px">
<TextBoxStyle Font-Size="0.8em" />
<LoginButtonSty le BackColor="#FFF BFF" BorderColor="#C CCCCC" BorderStyle="So lid"
BorderWidth="1p x" Font-Names="Verdana" Font-Size="0.8em" ForeColor="#284 775" />
<InstructionTex tStyle Font-Italic="True" ForeColor="Blac k" />
<TitleTextSty le BackColor="#5D7 B9D" Font-Bold="True" Font-Size="0.9em"
ForeColor="Whit e" />
</asp:Login>[/HTML]
And here is the code behind.... Default.aspx.cs
[HTML]using System;
using System.Collecti ons;
using System.Configur ation;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Secu rity;
using System.Web.UI;
using System.Web.UI.H tmlControls;
using System.Web.UI.W ebControls;
using System.Web.UI.W ebControls.WebP arts;
using System.Xml.Linq ;
using System.Data.Sql Client;
public partial class test : System.Web.UI.P age
{
protected void Page_Load(objec t sender, EventArgs e)
{
}
protected void Login1_Authenti cate(object sender, AuthenticateEve ntArgs e)
{
bool Authenticated = false;
Authenticated = SiteLevelCustom AuthenticationM ethod(Login1.Us erName, Login1.Password );
e.Authenticated = Authenticated;
if (Authenticated == true)
{
Response.Redire ct("Dashboard2. aspx");
}
}
private bool SiteLevelCustom AuthenticationM ethod(string UserName, string Password)
{
bool boolReturnValue = false;
// Insert code that implements a site-specific custom
// authentication method here.
// This example implementation always returns false.
System.Data.Sql Client.SqlConne ction conn = new SqlConnection(" Data Source=(local); Initial Catalog=DBhelpd esk; Integrated Security=SSPI;" );
conn.Open();
System.Data.Sql Client.SqlComma nd comm = new SqlCommand("sp_ ValidateUser", conn);
comm.Parameters .AddWithValue(" @UserName", UserName);
comm.Parameters .AddWithValue(" @Password", Password);
comm.CommandTyp e = CommandType.Sto redProcedure;
SqlDataReader Dr;
Dr = comm.ExecuteRea der();
while (Dr.Read())
{
boolReturnValue = true;
}
Dr.Close();
return boolReturnValue ;
}
}[/HTML]
Comment