Saturday, 12 July 2014

how to open new page of website in asp.net

Hello friends
Today i will tell you how to open a page in asp.net
Assume that you have two page first one is loginpage.aspx
and second one is registration.aspx page
you are in login page and you want to open a registration.aspx page when you click on login.aspx
page on button click event
So write following code in login page Button Click Event
Response.Redirect(/~registration.aspx)



Thanks 

Tuesday, 1 July 2014

How to Design login page in Asp.Net

Hello Friends
Today i will teach you how to design log in page in Asp.net with sql connectivity

Asp.net Coding
...........................
protected void Button1_Click(object sender, EventArgs e)
    {
        bool flag = false;
        SqlConnection con = new SqlConnection("Data Source=NIIT-PC;Initial Catalog=School;Integrated Security=True");
        con.Open();
        SqlCommand com=new SqlCommand("select count (*) from Login where Username='"+TextBox1.Text+"'and password='"+TextBox2.Text+"'",con);
        flag = Convert.ToBoolean(com.ExecuteScalar());
        if (flag == true)
        {
            Response.Redirect("~/Register.aspx");
        }
        else
        {
            Label1.Text = "incorrect user name And Password";
        }
       
        con.Close();

    }

SQl Coding

Create database School
create table login(username nvarchar(30),password nvarchar(30))
insert into login values('chetan','ravi');


Thanks