I am using the login status control in my master page.. My login control is a web custom control which i have created. When a user logs in i have redirected user to home.aspx. But it is not navigating/redirecting user to home.aspx... i have attached the code. plzz go throu and let me know where i have made a mistake..
MASTER PAGE :
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
=================================================================================
WEB USER CONTROL:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="login.ascx.cs" Inherits="login" %>
=========================================================================================
CODE BEHIND FOR WEB USER CONTROL:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
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.SqlClient;
public partial class login : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void imglogin_Click(object sender, ImageClickEventArgs e)
{
//try
//{
SqlConnection CON = new SqlConnection(ConfigurationManager.ConnectionStrings["ProjectTrackingConnectionString"].ConnectionString);
CON.Open();
SqlCommand cmd = new SqlCommand("select UserName,Password from login_master", CON);
SqlDataReader dtr;
dtr = cmd.ExecuteReader();
while (dtr.Read())
{
if ((dtr["UserName"].ToString() == txtuser.Text) && (dtr["Password"].ToString() == base64Decode(txtpassword.Text)))
{
Session["user"] = txtuser.Text;
Response.Redirect("home.aspx");
}
else
{
lblmsg.Text = "Invalid UserName/Password!";
}
}
dtr.Close();
CON.Close();
//}
//catch ()
//{
//}
}
public string base64Decode(string sData)
{
System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding();
System.Text.Decoder utf8Decode = encoder.GetDecoder();
byte[] todecode_byte = Convert.FromBase64String(sData);
int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length);
char[] decoded_char = new char[charCount];
utf8Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0);
string result = new String(decoded_char);
return result;
}
}
Kavita BPosted Jun 13, 2011, 2:20 AM
I have written all the code for login button in the custom control itself... I don`t know why it is not redirecting the user after logging in
Suthish NairPosted Jun 13, 2011, 1:58 AM