ASP.NET LAB MANUAL 1. ADDING TWO NUMBER PROCEDURE: No of labels : 3 No of textbox : 3 No of buttons : 1 CODING: Partial Class _Default Inherits System.Web.UI.Page Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Dim A, B, C As Integer A = TextBox1.Text B = TextBox2.Text C=A+B TextBox3.Text = C End Sub End Class OUTPUT:
A = TextBox1.Text B = TextBox2.Text If A > B Then TextBox3.Text = A Else TextBox3.Text = B End If End Sub Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click TextBox1.Text = "" TextBox2.Text = "" TextBox3.Text = "" End Sub Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load TextBox1.Focus() End Sub End Class OUTPUT:
3. FINDING EVEN OR ODD 2. BIGGEST OF TWO NUMBERS PROCEDURE: No of labels : 3 No of textbox : 3 No of buttons : 2 CODING: Partial Class _Default Inherits System.Web.UI.Page Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Dim A, B As Integer PROCEDURE: No of labels : 2 No of textbox : 2 No of buttons : 2 CODING: Partial Class _Default Inherits System.Web.UI.Page Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Dim N As Integer N = TextBox1.Text If N Mod 2 = 0 Then TextBox2.Text = N & " IS EVEN NUMBER " Else TextBox2.Text = N & " IS ODD NUMBER " End If End Sub
Page 1
4. REGISTRATION FORM PROCEDURE: No of labels : 5 No of textbox : 7 No of radio button: 2 No of checkbox : 3 No of button : 1 No of dropdownlist : 1 CODING: Partial Class _Default Inherits System.Web.UI.Page Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Dim A, B, C, D TextBox3.Text = "UR NAME IS " & TextBox1.Text TextBox4.Text = "UR PASSWORD IS " & TextBox2.Text If RadioButton1.Checked = True Then TextBox5.Text = "UR GENDER IS " & RadioButton1.Text Else TextBox5.Text = "UR GENDER IS " & RadioButton2.Text End If TextBox6.Text = "UR CITY IS " & DropDownList1.SelectedItem.Text If CheckBox1.Checked = True Then A = CheckBox1.Text End If If CheckBox2.Checked = True Then B = CheckBox2.Text End If If CheckBox1.Checked = True Then C = CheckBox3.Text End If
5. FINDING SELECTED AND NUMBER OF ITEMS PROCEDURE: No of labels : 1 No of textbox : 3 No of linkbutton : 4 No of dropdownlist : 1 CODING: Partial Class _Default Inherits System.Web.UI.Page Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton1.Click Dim A A = TextBox1.Text DropDownList1.Items.Add(A) TextBox1.Text = "" TextBox1.Focus() End Sub Protected Sub LinkButton2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton2.Click Dim B B = DropDownList1.SelectedItem.Text TextBox2.Text = B End Sub Protected Sub LinkButton3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton3.Click Dim C C = DropDownList1.Items.Count TextBox3.Text = C End Sub Protected Sub LinkButton4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton4.Click DropDownList1.Items.Clear() End Sub End Class OUTPUT:
Page 2
Page 3
CODING: <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1transitional.dtd"> <script runat ="server" > Sub submit(ByVal source As Object, ByVal e As EventArgs) Button1.Text = "YOU CLICKED ME!" End Sub </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <div> <asp:Button ID="Button1" text="CLICK ME" runat="server" onclick="submit" style="z-index: 100; left: 356px; position: absolute; top: 149px" FontNames="Arial Black" Font-Size="XX-Large" Width="486px" /> </div> </form> </body> </html> OUTPUT:
: :
2 1
Page 4
1 3 1
CODING: <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1transitional.dtd"> <script runat ="SERVER"> Sub SUBMIT(ByVal SENDER As Object, ByVal E As EventArgs) If RED.Checked Then
Page 5
11. ESTABLISHING A DATABASE CONECTIVITY PROCEDURE: Step 1: create a table in Microsoft access and copy. Step 2: create a new website. Step 3: go to solution explorer then paste the database that is copied under app_data. Step 4: place a gridview in the design page. Step 5: click the black triangle icon that is found on the right-top-end of the gridview. Step 6: in choose data source select <new data source> Next ->access database->ok->browse->app_data>database name select->ok->next->select * (or the cols and rows to be printed)->then finish. Step 7: run OUYPUT:
12. GENERATION OF CRYSTAL REPORT PROCEDURE: Step 1: create a new website. Step 2: create a database in access. Step 3: add a crystal report in the solution explorer. Step 4: place a crystal report viewer in the design page. Step 5: click the crystal report ->ok->create new connectionaccess/excel(dao)>click->select database name->finish->select table and press > ->next->next->-next->next->finish. Step 6: click the black triangle icon that is found on the right-top-end of the crystal report viewer. Step 7: choose report source <new report source ...> -> select the crystal report->ok. Step 8: run.
OUTPUT:
Page 6