Friday 29 November 2013

How to create a username and password page with login to another page?

Step 1-Firstly from toolbox select Label and select properties from solution explorer of label and change text "username"in demo.aspx web form..
Step 2-Similarly for password also select a Label and change text "password".
Step 3-Then straight to username label place textbox for the input of username.
Step 4-Similarly for password place a textbox.
Step 5-Then select validation from toolbox for both username and password.
For both regular expression validation is to be selected.
Step 6-For username change properties of validation where error message "enter email"
and control to validate "Textbox1",validation expression "\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" is to be given.
Step 7-Similarly for password validation property error message "enter password",control to validate "Textbox2",validation expression "\d{6}" is to be given. 
Step 8-Now from toolbox button is selected change properties from solution explorer where text "login",PostBackUrl "demo2.aspx" is to be selected.
Step 9-click the login button and write this code.
Code
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;


public partial class demo : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Label1.Text=TextBox1.Text;
        Label2.Text=TextBox2.Text;
    }
}

No comments:

Post a Comment