Login page when edit clicked in Gridview
-
Hi all i need a small help regarding gridview. I will show some information on loading a page. When ever a user clicks on Edit or delete it should redirect to a login page. Only the login user can edit or delete the data. How can i do this.
-
Hi all i need a small help regarding gridview. I will show some information on loading a page. When ever a user clicks on Edit or delete it should redirect to a login page. Only the login user can edit or delete the data. How can i do this.
By checking whether user is logged in or not on edit & delete click. :^)
-
By checking whether user is logged in or not on edit & delete click. :^)
Can i have the sample code
-
Can i have the sample code
Sure, but first tell me, what are you doing for Login functionality?
-
Can i have the sample code
-
Sure, but first tell me, what are you doing for Login functionality?
Just a basic login like this protected void Button1_Click(object sender, EventArgs e) { SqlConnection Con = new SqlConnection(ConfigurationManager.AppSettings["sqlcon"]); SqlCommand cmd = new SqlCommand(); cmd.Connection = Con; string sql; sql = "Select *from login where uname='" + TextBox1.Text + "' and pwd='" + TextBox2.Text + "'"; cmd.CommandText = sql; Con.Open(); SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { Response.Redirect("Default.aspx"); } }
-
Just a basic login like this protected void Button1_Click(object sender, EventArgs e) { SqlConnection Con = new SqlConnection(ConfigurationManager.AppSettings["sqlcon"]); SqlCommand cmd = new SqlCommand(); cmd.Connection = Con; string sql; sql = "Select *from login where uname='" + TextBox1.Text + "' and pwd='" + TextBox2.Text + "'"; cmd.CommandText = sql; Con.Open(); SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { Response.Redirect("Default.aspx"); } }
This is not a proper Login. You need to use either Session Variables or FormsAuthentication Class. For more details, please use Google.
-
Just a basic login like this protected void Button1_Click(object sender, EventArgs e) { SqlConnection Con = new SqlConnection(ConfigurationManager.AppSettings["sqlcon"]); SqlCommand cmd = new SqlCommand(); cmd.Connection = Con; string sql; sql = "Select *from login where uname='" + TextBox1.Text + "' and pwd='" + TextBox2.Text + "'"; cmd.CommandText = sql; Con.Open(); SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { Response.Redirect("Default.aspx"); } }
OH Great..! First Try to read a good book..! Did You Know abt forms authentication..!First try to read abt forms authentication..!
check the
protected void ConfirmDataGrid_ItemCommand(object sender, DataGridCommandEventArgs e)
{
if (e.CommandName ="edit")
{
//Write Your Logic Here if the user is Login user
//If the user is not logged in Redirect From here..!} }
LatestArticle :Log4Net Why Do Some People Forget To Mark as Answer .If It Helps.
-
Hi all i need a small help regarding gridview. I will show some information on loading a page. When ever a user clicks on Edit or delete it should redirect to a login page. Only the login user can edit or delete the data. How can i do this.
Hey i just write it for sample. I know form authentication and other . Please provide me what to do after log in success.
-
Hey i just write it for sample. I know form authentication and other . Please provide me what to do after log in success.
using System; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.Data.SqlClient; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ViewState["Loginerrors"] = 0; } } private bool validate(String Uname, String Pwd) { bool val = false; SqlConnection con = new SqlConnection(ConfigurationSettings.AppSettings["sqlcon"].ToString()); string qry = "Select Uname, Pwd FROM login"; SqlCommand cmd = new SqlCommand(qry, con); SqlDataReader dr; con.Open(); dr = cmd.ExecuteReader(); while (dr.Read()) { if ((Uname == dr["Uname"].ToString()) & (Pwd == dr["Pwd"].ToString())) { val = true; } dr.Close(); return val; } return val; } protected void Login1_Authenticate(object sender, EventArgs e) { if (validate(Login1.UserName,Login1.Password)) { Login1.Visible = false; Label1.Text = "Success"; } else { Label1.Text = "Failed"; } } } Is this code efficient for login