Registration Form Using Two Webpages

Satyapriyanayak
Posted by Satyapriyanayak under ASP.NET category on | Points: 40 | Views : 921

FirstForm.aspx
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="FirstForm.aspx.vb" Inherits="FirstForm" %>
<head runat="server">
</head>
<body>
<form id="form1" runat="server">
<asp:Label ID="Label1" runat="server" Text="First Name" Width="160px"
Font-Bold="True"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server" Width="200px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="TextBox1" ErrorMessage="Name Required"></asp:RequiredFieldValidator>
<asp:Label ID="Label2" runat="server" Text="Email" Width="160px"
Font-Bold="True"></asp:Label>
<asp:TextBox ID="TextBox2" runat="server" Width="200px"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="TextBox2" ErrorMessage="Invalid Email"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="TextBox2" ErrorMessage="Email Required"></asp:RequiredFieldValidator>
<asp:Label ID="Label3" runat="server" Text="Mobile No" Width="160px"
Font-Bold="True"></asp:Label>
<asp:TextBox ID="TextBox3" runat="server" Width="200px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="TextBox3" ErrorMessage="Mobile No. Required"></asp:RequiredFieldValidator>
<asp:Label ID="Label4" runat="server" Text="Country" Width="160px"
Font-Bold="True"></asp:Label>
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem>India</asp:ListItem>
<asp:ListItem>usa</asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
ControlToValidate="DropDownList1" ErrorMessage="Country Required"></asp:RequiredFieldValidator>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click"
Text="Register continue to next page" Font-Bold="True" />
</form>
</body>
</html>

FirstForm.aspx.vb
Imports System.Data.SqlClient
Imports System.Data
Partial Class FirstForm
Inherits System.Web.UI.Page
Dim strConnString As String = System.Configuration.ConfigurationManager.ConnectionStrings.Item("ConnectionString").ToString()
Dim con As New SqlConnection(strConnString)
Dim sqlda As SqlDataAdapter
Dim com As SqlCommand
Dim ds As DataSet
Dim str As String
Dim url As String
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
url = "SecondForm.aspx?name=" & TextBox1.Text & "&email=" & TextBox2.Text & "&mobileno=" & TextBox3.Text & " &country=" & DropDownList1.SelectedItem.Text
Response.Redirect(url)
End Sub
End Class
SecondForm.aspx code
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="SecondForm.aspx.vb" Inherits="SecondForm" %>
<body>
<form id="form1" runat="server">
<asp:Label ID="Label1" runat="server" Text=" Email:*" Width="160px"
Font-Bold="True"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server" Width="200px"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="TextBox1" ErrorMessage="Invalid email"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
<asp:Label ID="Label2" runat="server" Text=" Password:*" Width="160px" Font-Bold="True"></asp:Label>
<asp:TextBox ID="TextBox2" runat="server" Width="200px" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox2" ErrorMessage="Password Required"></asp:RequiredFieldValidator>
<asp:Label ID="Label3" runat="server" Text=" Confirm Password:*" Width="160px" Font-Bold="True"></asp:Label>
<asp:TextBox ID="TextBox3" runat="server" Width="200px" TextMode="Password"></asp:TextBox>
<asp:CompareValidator ID="CompareValidator2" runat="server" ControlToCompare="TextBox2" ControlToValidate="TextBox3"
ErrorMessage="Password mismatch"></asp:CompareValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="TextBox3" ErrorMessage="ConfirmPassword Required"></asp:RequiredFieldValidator>
<asp:Label ID="Label4" runat="server" Text="First Name:*" Width="160px" Font-Bold="True"></asp:Label>
<asp:TextBox ID="TextBox4" runat="server" Width="200px"></asp:TextBox>
<asp:Label ID="Label5" runat="server" Text=" Last Name:*" Width="160px" Font-Bold="True"></asp:Label>
<asp:TextBox ID="TextBox5" runat="server" Width="200px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="TextBox5" ErrorMessage="Last Name Required"></asp:RequiredFieldValidator>
<asp:Label ID="Label6" runat="server" Text="Mobile Number: *" Width="160px" Font-Bold="True"></asp:Label>
<asp:TextBox ID="TextBox6" runat="server" Width="200px"></asp:TextBox>
<asp:Label ID="Label7" runat="server" Text="You have selected: *" Width="160px" Font-Bold="True"></asp:Label>
<asp:DropDownList ID="DropDownList1" runat="server"></asp:DropDownList>
<asp:Button ID="Button1" runat="server" Text="Confirm Register" onclick="Button1_Click" Font-Bold="True" />
</form>
</body>
</html>
SecondForm.aspx.vb
Imports System.Data.SqlClient
Imports System.Data
Partial Class SecondForm
Inherits System.Web.UI.Page
Dim strConnString As String = System.Configuration.ConfigurationManager.ConnectionStrings.Item("ConnectionString").ToString()
Dim con As New SqlConnection(strConnString)
Dim sqlda As SqlDataAdapter
Dim com As SqlCommand
Dim ds As DataSet
Dim str As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
TextBox4.Text = Request.QueryString("name")
TextBox1.Text = Request.QueryString("email")
TextBox6.Text = Request.QueryString("mobileno")
DropDownList1.Items.Add(Request.QueryString("country"))
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
con.Open()
Session("fname") = TextBox4.Text
Session("lname") = TextBox5.Text
str = "insert into employee values('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & Session("fname") & "','" & Session("lname") & "','" & TextBox6.Text & "','" & DropDownList1.SelectedValue & "')"
com = New SqlCommand(str, con)
com.ExecuteNonQuery()
con.Close()
End Sub
End Class

Comments or Responses

Login to post response