Skip to content
Loading
login and logout in Asp.net

© <%: DateTime.Now.Year %> - My ASP.NET Application

0
  • Mangesh G
    Hello air can you post the log out code please On log out simply right Response.redirect(your login page url)
    0
  • Abdalla Elawad

    Hello My Dear  Mangesh Gaherwar

    This is login code :
     
    Hello My Dear
     
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Data.SqlClient;
    using System.Data;
    using System.Data.SqlTypes;
    using System.Configuration;
    using System.Drawing;
    namespace LoginPage_logoutPage
    {
    public partial class loginPage : System.Web.UI.Page
    {
    SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["Con_Inventory"].ToString());
    protected void Page_Load(object sender, EventArgs e)
    {
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
    con.Open();
    string query = "select count(*)from tbl_users where UserName='" + txtname.Text + "' and Password='" + txtpass.Text + "' ";
    SqlCommand cmd = new SqlCommand(query, con);
    string output = cmd.ExecuteScalar().ToString();
    if (output == "1")
    {
    Session["User"] = txtname.Text;
    Response.Redirect("~/Default.aspx");
    }
    else
    {
    Response.Write("Invalid User Name Or Password");
    }
    }
    }
    }
     
    0
  • Mangesh G
    What code u r writing on logout
    0