asp .net programs

63
 ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA Roll No 86 RATHOD AJAY A. TYBCA NGCCA Unit:-1 Introduction Que:-1 Create an application which count the total number of users visited the page. (Using global.asax). Global.asax <%@ Application Language="VB" %> <script runat="server" Language="vb"> Public i As Integer = 1 Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs) Application("NoOfVisitors") = 0 ' Code that runs on application startup End Sub Sub Application_End(ByVa l sender As Object, ByVal e As EventArgs) ' Code that runs on application shutdown End Sub Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs) ' Code that runs when an unhandled error occurs End Sub Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs) i += 1 Application.Lock() Application("NoOfVisitors") = CInt(Application("NoOfVisitors")) + 1 Application.UnLock() ' MsgBox(i) ' Code that runs when a new session is started End Sub Sub Session_End(ByVal sender As Object, ByVal e As EventArgs) ' Code that runs when a session ends. ' Note: The Session_End event is raised only when the sessionstate mode ' is set to InProc in the Web.config file. If session mode is set to StateServer ' or SQLServer, the event is not raised. End Sub

Upload: rathodajax

Post on 18-Oct-2015

105 views

Category:

Documents


9 download

DESCRIPTION

bca syllabus programs for asp.netposted by ajay rathod and sahil darz.

TRANSCRIPT

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    Roll No 86 RATHOD AJAY A. TYBCA NGCCA

    Unit:-1 Introduction Que:-1 Create an application which count the total number of users visited the page. (Using global.asax). Global.asax

    Public i As Integer = 1

    Sub Application_Start(ByVal sender As Object, ByVal e

    As EventArgs)

    Application("NoOfVisitors") = 0

    ' Code that runs on application startup

    End Sub

    Sub Application_End(ByVal sender As Object, ByVal e

    As EventArgs)

    ' Code that runs on application shutdown

    End Sub

    Sub Application_Error(ByVal sender As Object, ByVal e

    As EventArgs)

    ' Code that runs when an unhandled error occurs

    End Sub

    Sub Session_Start(ByVal sender As Object, ByVal e As

    EventArgs)

    i += 1

    Application.Lock()

    Application("NoOfVisitors") =

    CInt(Application("NoOfVisitors")) + 1

    Application.UnLock()

    ' MsgBox(i)

    ' Code that runs when a new session is started

    End Sub

    Sub Session_End(ByVal sender As Object, ByVal e As

    EventArgs)

    ' Code that runs when a session ends.

    ' Note: The Session_End event is raised only when the

    sessionstate mode

    ' is set to InProc in the Web.config file. If session

    mode is set to StateServer

    ' or SQLServer, the event is not raised.

    End Sub

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    Default.aspx

    Untitled Page

    Default.aspx.vb

    Imports System

    Partial Class _Default

    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal

    e As System.EventArgs) Handles Me.Load

    Label1.Text = "Total Visit is " &

    Application("NoOfVisitors").ToString()

    End Sub

    End Class

    Output

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    Que:-2 Create web page which will display School mark

    sheet using table control.

    Default.aspx

    Untitled Page

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    Chimanbhai Patel Institute Of Computer

    Apllication

    Seat

    NO.380

    Name.

    Jibin George

    Year.December 2013

    Enrolment No.20111213337

    Subject Name

    Cradit

    Marks

    Totla

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    Internal

    External

    C Programing

    3

    29

    65

    94

    Introduction to Internet and

    HTML

    3

    30

    67

    97

    Basic Of

    Mathenatics

    3

    25

    40

    65

    Computer

    Fondamentals

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    3

    25

    55

    80

    C Programing

    Practicle

    3

    30

    70

    100

    HTML

    Practicale

    3

    30

    70

    100

    Totle

    18

    169

    367

    536

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    Output

    Que : 3 Create web page which will ask the employee personal detail, education detail, work experience detail with use different panel for each part . Default.aspx

    Untitled Page

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    Emp Name :

    Emp Age :

    Emp Date OF Birth

    :

    Employee

    Personal Detail

    SSC Percentage

    :

    Year to pass

    SSC :

    HSC Percentage

    :

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    Year to pass

    HSC :

    Employee

    Education Detail

    Post of Last

    job

    Number Of Munth

    Leave Date of Last

    Job:

    Employee

    Experience Detail

    Output

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    Que : 4 Create web page which will ask payment detail of custome purchase, this detail either in Cash or Credit/Debit card or by Cheque. According to the payment mode panel control will display and accept payment detail and display all that detail in next page using label control. Default.aspx

    Untitled Page

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    Case payment

    Credit/Debit payment

    Cheque payment

    Default.aspx.vb Partial Class _Default

    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As

    System.EventArgs) Handles Button1.Click

    Application("ch_no") = TextBox1.Text

    Application("ch_exdate") = TextBox2.Text

    Application("amount") = TextBox3.Text

    Application("panal") = 3

    Response.Redirect("Default2.aspx")

    End Sub

    Protected Sub Button2_Click(ByVal sender As Object, ByVal e As

    System.EventArgs) Handles Button2.Click

    Application("Credit_no") = TextBox4.Text

    Application("Credit_exdate") = TextBox5.Text

    Application("amount") = TextBox6.Text

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    Application("panal") = 2

    Response.Redirect("Default2.aspx")

    End Sub

    Protected Sub Button3_Click(ByVal sender As Object, ByVal e As

    System.EventArgs) Handles Button3.Click

    Application("coine") = TextBox7.Text

    Application("silak") = TextBox8.Text

    Application("amount") = TextBox9.Text

    Application("panal") = 1

    Response.Redirect("Default2.aspx")

    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As

    System.EventArgs) Handles Me.Load

    Panel1.Visible = False

    Panel2.Visible = False

    Panel3.Visible = False

    End Sub

    Protected Sub RadioButtonList1_SelectedIndexChanged(ByVal

    sender As Object, ByVal e As System.EventArgs) Handles

    RadioButtonList1.SelectedIndexChanged

    If RadioButtonList1.SelectedIndex = 0 Then

    Panel3.Visible = True

    Panel1.Visible = False

    Panel2.Visible = False

    ElseIf RadioButtonList1.SelectedIndex = 1 Then

    Panel2.Visible = True

    Panel1.Visible = False

    Panel3.Visible = False

    Else

    Panel1.Visible = True

    Panel2.Visible = False

    Panel3.Visible = False

    End If

    End Sub

    End Class

    Default2.aspx

    Untitled Page

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    Default2.aspx.vb Partial Class Default2

    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As

    System.EventArgs) Handles Me.Load

    Panel1.Visible = False

    Panel2.Visible = False

    Panel3.Visible = False

    If Application("panal") = "1" Then

    Panel3.Visible = True

    Label16.Text = Application("coine")

    Label17.Text = Application("silak")

    Label18.Text = Application("amount")

    ElseIf Application("panal") = "2" Then

    Panel2.Visible = True

    Label19.Text = Application("Credit_no")

    Label20.Text = Application("Credit_exdate")

    Label21.Text = Application("amount")

    ElseIf Application("panal") = "3" Then

    Panel1.Visible = True

    Label13.Text = Application("ch_no")

    Label14.Text = Application("ch_exdate")

    Label15.Text = Application("amount")

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    End If

    End Sub

    End Class

    Output

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    Que : 5 Write a program that displays a label in green color and it should change into yellow when the mouse moves over it. Default.aspx

    Untitled Page

    a.chng_lab{background-color : green;}

    a:hover.chng_lab {background-color : yellow;}

    Output

    Unit:-2 Web Controls

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    Que:-1 Write a simple ASP.NET program to display the following Web Controls: A button with text click me. The button control must be in the center of the form. A label with a text hello A checkbox. The form name must be Web Controls. Default.aspx

    Untitled Page

    Select File

    Name

    Default.aspx.vb

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    Partial Class _Default

    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As

    System.EventArgs) Handles Button1.Click

    Label1.Text = "HELLO"

    End Sub

    Protected Sub CheckBox1_CheckedChanged(ByVal sender As Object,

    ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged,

    CheckBox2.CheckedChanged, CheckBox3.CheckedChanged,

    CheckBox4.CheckedChanged

    If sender.text = "First" Then

    Me.Title = "First"

    CheckBox2.Checked = False

    CheckBox3.Checked = False

    CheckBox4.Checked = False

    ElseIf sender.text = "Second" Then

    Me.Title = "Second"

    CheckBox1.Checked = False

    CheckBox3.Checked = False

    CheckBox4.Checked = False

    ElseIf sender.text = "Third" Then

    Me.Title = "Third"

    CheckBox1.Checked = False

    CheckBox2.Checked = False

    CheckBox4.Checked = False

    Else

    Me.Title = "Forth"

    CheckBox1.Checked = False

    CheckBox2.Checked = False

    CheckBox3.Checked = False

    End If

    End Sub

    End Class

    Output :

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    Que : 2 Write a program to display Hello World in the form when the click button is clicked. The Form title must be ASP.NET. Default.aspx

    Untitled Page

    Default.aspx.vb

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    Partial Class _Default

    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As

    System.EventArgs) Handles Button1.Click

    Me.Title = "Hello World"

    End Sub

    End Class

    Que : 3 Write a program containing the following controls: A ListBox

    A Button An Image A Label The listbox is used to list items available in a store. When the user clicks on an item in the listbox, its image is displayed in the image control. When the user clicks the button, the cost of the

    selected item is displayed in the control.

    Default.aspx

    Untitled Page

    Books

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    C balagurusamy

    C++ balagurusamy

    beginning java4

    Beginning Android4

    PHP

    Asp.net Black Book

    Default.aspx.vb Partial Class _Default

    Inherits System.Web.UI.Page

    Protected Sub ListBox1_SelectedIndexChanged(ByVal sender As

    Object, ByVal e As System.EventArgs) Handles

    ListBox1.SelectedIndexChanged

    Label1.Text = "Price ::"

    If ListBox1.SelectedIndex = 0 Then

    Image1.ImageUrl = "Images\c.gif"

    ElseIf ListBox1.SelectedIndex = 1 Then

    Image1.ImageUrl = "~\Images\cpp.jpg"

    ElseIf ListBox1.SelectedIndex = 2 Then

    Image1.ImageUrl = "~\Images\java.jpg"

    ElseIf ListBox1.SelectedIndex = 3 Then

    Image1.ImageUrl = "~\Images\android.jpg"

    ElseIf ListBox1.SelectedIndex = 4 Then

    Image1.ImageUrl = "~\Images\php.jpg"

    ElseIf ListBox1.SelectedIndex = 5 Then

    Image1.ImageUrl = "~\Images\asp.jpg"

    End If

    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As

    System.EventArgs) Handles Button1.Click

    Label1.Text += " " & ListBox1.SelectedValue

    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As

    System.EventArgs) Handles Me.Load

    End Sub

    End Class

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    Output

    Que:- 4 Extend the above program to add the following controls: Two labels A TextBox A Button One of the labels is displayed adjacent to the textbox, displaying the message Enter the quantity: When the user enters the quantity in the textbox and clicks the button, the total cost is evaluated and displayed in another label.

    Default.aspx

    Untitled Page

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    Default.aspx.vb Partial Class _Default

    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As

    System.EventArgs) Handles Button1.Click

    Label2.Text = Val(TextBox1.Text) * 100

    End Sub

    End Class

    Output

    Que : 5 Create a RadioButtonList that displays the names of some flowers in two columns. Bind a label to the RadioButtonList so that when the user selects an option from the list and clicks on a button, the label displays the flower selected by the user.

    Default.aspx

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    Untitled Page

    Lisianthus

    peony

    poinsettia

    protea

    rose

    sunflower

    Default.aspx.vb Partial Class _Default

    Inherits System.Web.UI.Page

    Protected Sub RadioButtonList1_SelectedIndexChanged(ByVal

    sender As Object, ByVal e As System.EventArgs) Handles

    RadioButtonList1.SelectedIndexChanged

    If RadioButtonList1.SelectedIndex = 0 Then

    Image1.ImageUrl = "Images\Lisianthus.jpg"

    ElseIf RadioButtonList1.SelectedIndex = 1 Then

    Image1.ImageUrl = "Images\peony.jpg"

    ElseIf RadioButtonList1.SelectedIndex = 2 Then

    Image1.ImageUrl = "Images\poinsettia.jpg"

    ElseIf RadioButtonList1.SelectedIndex = 3 Then

    Image1.ImageUrl = "Images\protea.jpg"

    ElseIf RadioButtonList1.SelectedIndex = 4 Then

    Image1.ImageUrl = "Images\rose.jpg"

    ElseIf RadioButtonList1.SelectedIndex = 5 Then

    Image1.ImageUrl = "Images\sunflower.jpg"

    End If

    End Sub

    End Class

    Output

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    Que : 6 Create a user control that contains a list of colors. Add a

    button to the Web Form which when clicked changes the color of the

    Form to the color selected from the list.

    Default.aspx

    Untitled Page

    Red

    Pink

    Blue

    Orange

    Green

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    Yellow

    Lavender

    Select One Color and

    chage the background color

    of the form

    Default.aspx.vb Partial Class _Default

    Inherits System.Web.UI.Page

    Protected Sub ListBox1_SelectedIndexChanged(ByVal sender As

    Object, ByVal e As System.EventArgs) Handles

    ListBox1.SelectedIndexChanged

    body_page.Attributes("bgcolor") = ListBox1.SelectedItem.Text

    End Sub

    End Class

    Output

    Que : 7 Create a new Web form which allows the client to enterstudent information such as name, email address, sex and telephone numer. The page also provides a submit button, which when clicked, will add this information to a TextBox which will also be displayed on the same page. Default.aspx

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    Untitled Page

    Man

    Woman

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    BorderStyle="Dotted" Columns="4" ForeColor="Black"

    Height="128px" Style="z-index: 110;

    left: 28px; position: absolute; top: 297px"

    TextMode="MultiLine" Width="254px">

    Default.aspx.vb Partial Class _Default

    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As

    System.EventArgs) Handles Button1.Click

    TextBox4.Text = "Name : " & TextBox1.Text &

    Environment.NewLine

    TextBox4.Text += "Email ID : " & TextBox2.Text & vbCrLf

    TextBox4.Text += "Sex : " & RadioButtonList1.SelectedItem.Text

    & Constants.vbCrLf

    TextBox4.Text += "Phone Number : " & TextBox3.Text

    End Sub

    End Class

    Output

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    Que : 8 Create a product catalog facility for an online mobile store. The web page will display multiple mobile phone photos and their prices. When user clicks on any particular photo, he or she should be navigated to the page for that mobile. This page will contain all

    details and features of selected mobile phone. Default.aspx

    Untitled Page

    Nokia673f

    Nokia678b

    Nokia6260

    Nokia7600

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    Default.aspx.vb Partial Class _Default

    Inherits System.Web.UI.Page

    Protected Sub ListBox1_SelectedIndexChanged(ByVal sender As

    Object, ByVal e As System.EventArgs) Handles

    ListBox1.SelectedIndexChanged

    If ListBox1.SelectedIndex = 0 Then

    Image1.ImageUrl = "673f_1.JPG"

    ElseIf ListBox1.SelectedIndex = 1 Then

    Image1.ImageUrl = "678b_1.jpg"

    ElseIf ListBox1.SelectedIndex = 2 Then

    Image1.ImageUrl = "img_med_6260.jpg"Else

    Image1.ImageUrl = "img_med_7600.jpg"

    End If

    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As

    System.EventArgs) Handles Button1.Click

    If ListBox1.SelectedIndex = 0 Then

    Label1.Text = "15000"

    ElseIf ListBox1.SelectedIndex = 1 Then

    Label1.Text = "17000"

    ElseIf ListBox1.SelectedIndex = 2 Then

    Label1.Text = "7000"

    Else

    Label1.Text = "6000"

    End If

    End Sub

    End Class

    Output

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    Que : 9 Develop an application which allow user to upload a .jpeg file and display it in an image box on the same page. Default.aspx

    Untitled Page

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    Default.aspx.vb 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 path As String

    path = Server.MapPath("~/")

    FileUpload1.SaveAs(path + FileUpload1.FileName)

    Imagebox1.ImageUrl = FileUpload1.PostedFile.FileName

    End Sub

    End Class

    Output :

    Unit : 3 Validation Controls ASP.NET Objects and Data Collection Class Que:-1 Write a program that gets user input such as the user name, mode of payment, appropriate credit card. After

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    the user enters the appropriate values the Validation button validates the values entered. Default.aspx

    Untitled Page

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    Output

    Que : 2 Create a Form that receives the user name, address, date, nationality, country preferred for working and skill sets from the user. The country preferred data should appear in a dropdownlist whereas; others should be entered in a textbox. Validate all the controls. The Form is named formexp.aspx. The date should appear between 1/1/1900 and 1/1/2090. formexp.aspx

    Untitled Page

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    top: 280px">

    India

    China

    US

    UK

    Japan

    OUTPUT :

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    Que : 3 Create a user control that receives the user name and password from the user and validates them. If the user name is ASP and the password is NET then the user is authorized, otherwise not. Default.aspx

    Untitled Page

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    Default.aspx.vb Partial Class _Default

    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As

    System.EventArgs) Handles Button1.Click

    If TextBox1.Text = "ASP" And TextBox2.Text = "NET" Then

    MsgBox("Admin Login Successfully")

    Else

    MsgBox("User Login Successfully")

    End If

    End Sub

    Protected Sub CheckBox1_CheckedChanged(ByVal sender As Object,

    ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged

    If CheckBox1.Checked Then

    TextBox2.TextMode = TextBoxMode.SingleLine

    Else

    TextBox2.TextMode = TextBoxMode.Password

    End If

    End Sub

    End Class

    Output

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    Que : 4 Accept ItemCode, ItemName, ItemPrice and Qty from the user, store it as cookies and then display them on the next page. Global.asax

    Sub Application_Start(ByVal sender As Object, ByVal e As

    EventArgs)

    ' Code that runs on application startup

    End Sub

    Sub Application_End(ByVal sender As Object, ByVal e As

    EventArgs)

    Response.Cookies("itemcode").Expires = Now

    Response.Cookies("itemname").Expires = Now

    Response.Cookies("itemprice").Expires = Now

    Response.Cookies("itemqty").Expires = Now

    End Sub

    Sub Application_Error(ByVal sender As Object, ByVal e As

    EventArgs)

    ' Code that runs when an unhandled error occurs

    End Sub

    Sub Session_Start(ByVal sender As Object, ByVal e As

    EventArgs)

    ' Code that runs when a new session is started

    End Sub

    Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)

    ' Code that runs when a session ends.

    ' Note: The Session_End event is raised only when the

    sessionstate mode

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    ' is set to InProc in the Web.config file. If session mode is

    set to StateServer

    ' or SQLServer, the event is not raised.

    End Sub

    Default.aspx

    Untitled Page

    Default.aspx.vb

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    Partial Class _Default

    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As

    System.EventArgs) Handles Button1.Click

    Response.Cookies("itemcode1").Value = TextBox1.Text

    Response.Cookies("itemname1").Value = TextBox2.Text

    Response.Cookies("itemprice1").Value = TextBox3.Text

    Response.Cookies("itemqty1").Value = TextBox4.Text

    Response.Redirect("default2.aspx")

    End Sub

    End Class

    Default2.aspx

    Untitled Page

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    Default2.aspx.vb Partial Class Default2

    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As

    System.EventArgs) Handles Me.Load

    'MsgBox(Request.Cookies("name").Value.ToString)

    Label5.Text = Request.Cookies("itemcode1").Value.ToString

    Label6.Text = Request.Cookies("itemname1").Value.ToString

    Label7.Text = Request.Cookies("itemprice1").Value.ToString

    Label8.Text = Request.Cookies("itemqty1").Value.ToString

    End Sub

    End Class

    Output

    Que : 7 Create a table StudentInfo, which contain rollno, name and year of a student. And also create a table StudentScore which contain marks of three subjects for each student. Display name of all the students in a DropDownList and according to users choice, particular student record should display in a FormView/DetailView control.

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    Default.aspx

    Untitled Page

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    left: 304px; position: absolute; top: 208px" Width="128px">

    rollno:

    name:

    age:

    rollno:

    name:

    age:

    rollno:

    name:

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    age:

    Default.aspx.vb Imports System.Data.SqlClient

    Partial Class _Default

    Inherits System.Web.UI.Page

    Dim con As New SqlConnection("Data

    Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Dhara\Documents\

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    Visual Studio

    2005\WebSites\ch3_7\App_Data\Database.mdf;Integrated

    Security=True;User Instance=True")

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As

    System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender

    As Object, ByVal e As System.EventArgs) Handles

    DropDownList1.SelectedIndexChanged

    FormView1.PageIndex = DropDownList1.SelectedIndex

    DetailsView1.PageIndex = DropDownList1.SelectedIndex

    End Sub

    End Class

    Output

    Unit:-4 I/O and ADO.NET

    Que : 1 Develop a web application to reserve online in a hotel. The user should enter date of arrival, number of days, room type, number of persons etc. He would be able to confirm booking and allowed to pay advance on confirmation. Default.aspx

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    Untitled Page

    Select Any One

    Single Bad

    Double Bad

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    Default.aspx.vb Partial Class _Default

    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As

    System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As

    System.EventArgs) Handles Button1.Click

    Dim i As Integer

    i = MsgBox("Comform Your order??", MsgBoxStyle.YesNo)

    If i = 6 Then

    Response.Redirect("Default2.aspx")

    End If

    End Sub

    Protected Sub Button2_Click(ByVal sender As Object, ByVal e As

    System.EventArgs) Handles Button2.Click

    Calendar1.Visible = True

    End Sub

    Protected Sub Calendar1_SelectionChanged(ByVal sender As

    Object, ByVal e As System.EventArgs) Handles

    Calendar1.SelectionChanged

    Calendar1.Visible = False

    Dim a, b As Date

    a = Calendar1.SelectedDate

    b = Calendar1.TodaysDate

    If b

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    top: 80px" Text="CVV :">

    top: 120px" Text="End Of Date">

    Default2.aspx.vb Partial Class Default2

    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As

    System.EventArgs) Handles Button1.Click

    MsgBox("Your order is Submited")

    End Sub

    End Class

    Output

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    Que : 2 Create an application to display all records from an Employee table with proper formatting. Default.aspx

    Untitled Page

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    eno:

    ename:

    designation:

    salary:

    eno:

    ename:

    designation:

    salary:

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    eno:

    ename:

    designation:

    salary:

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    Default.aspx.vb Imports System.Data.SqlClient

    Partial Class _Default

    Inherits System.Web.UI.Page

    Dim con As New SqlConnection("Data

    Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Dhara\Documents\

    Visual Studio 2005\WebSites\ch4_4\App_Data\emp1.mdf;Integrated

    Security=True;User Instance=True")

    Dim cmd As SqlCommand

    Dim i As Integer = 0

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As

    System.EventArgs) Handles Me.Load

    Dim tc1 As New TableCell

    Dim tc2 As New TableCell

    Dim tc3 As New TableCell

    Dim tc4 As New TableCell

    Dim r As New TableRow

    con.Open()

    cmd = New SqlCommand("select * from emp", con)

    Dim dr As SqlDataReader

    cmd.ExecuteNonQuery()

    dr = cmd.ExecuteReader

    End Sub

    End Class

    Output

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    Que : 3 Write a simple Web application which reads off a table in an Access database file and display the data in a Web form. Default.aspx

    Untitled Page

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    Default.aspx.vb Imports System.Data.OleDb

    Partial Class _Default

    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As

    System.EventArgs) Handles Me.Load

    Dim con As New

    OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data

    Source=E:\Collage\sem 6\asp.net\ch4\ch4_5\EMP.mdb")

    Dim cmd As OleDbCommand

    con.Open()

    cmd = New OleDbCommand("select * from EMPLOYEE", con)

    Dim dr As OleDbDataReader

    dr = cmd.ExecuteReader

    GridView1.DataSource = dr

    GridView1.DataBind()

    con.Close()

    End Sub

    End Class

    Output

    Que : 4 Develop an application for online booking for a picture in a cinema hall. User should be able to select date,

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    time, picture and tickets. If the tickets are available user should be able to generate ticket. Global.asax

    Sub Application_Start(ByVal sender As Object, ByVal e As

    EventArgs)

    ' Code that runs on application startup

    Application("val") = 0

    End Sub

    Sub Application_End(ByVal sender As Object, ByVal e As

    EventArgs)

    ' Code that runs on application shutdown

    End Sub

    Sub Application_Error(ByVal sender As Object, ByVal e As

    EventArgs)

    ' Code that runs when an unhandled error occurs

    End Sub

    Sub Session_Start(ByVal sender As Object, ByVal e As

    EventArgs)

    ' Code that runs when a new session is started

    Application("val") = Application("val") + 1

    End Sub

    Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)

    ' Code that runs when a session ends.

    ' Note: The Session_End event is raised only when the

    sessionstate mode

    ' is set to InProc in the Web.config file. If session mode is

    set to StateServer

    ' or SQLServer, the event is not raised.

    End Sub

    Default.aspx

    Untitled Page

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    Default.aspx.vb Imports System.Data.SqlClient

    Partial Class _Default

    Inherits System.Web.UI.Page

    Dim con As New SqlConnection("Data

    Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Dhara\Documents\

    Visual Studio

    2005\WebSites\ch4_7\App_Data\Database.mdf;Integrated

    Security=True;User Instance=True")

    Dim cmd As SqlCommand

    Dim i As Integer = 0

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As

    System.EventArgs) Handles Button1.Click

    con.Open()

    cmd = New SqlCommand("insert into bill values(" &

    Application("val") & ",'" & DropDownList1.SelectedValue &

    "','" & TextBox2.Text & "','" & TextBox4.Text & "'," &

    CInt(TextBox4.Text) * CInt(TextBox3.Text) & ")", con)

    cmd.ExecuteNonQuery()

    Label9.Text = DropDownList1.SelectedValue

    Label10.Text = TextBox2.Text

    Label11.Text = TextBox3.Text

    Label12.Text = TextBox4.Text

    Panel1.Visible = True

    con.Close()

    End Sub

    Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender

    As Object, ByVal e As System.EventArgs) Handles

    DropDownList1.SelectedIndexChanged

    Panel1.Visible = False;

    con.Open()

    cmd = New SqlCommand("select * from movie where name='" &

    DropDownList1.SelectedValue & "'", con)

    cmd.ExecuteNonQuery()

    Dim dr As SqlDataReader

    dr = cmd.ExecuteReader

    While dr.Read

    TextBox2.Text = dr(2)

    TextBox3.Text = dr(3)

    End While

    con.Close()

    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As

    System.EventArgs) Handles Me.Load

    Panel1.Visible = False

    End Sub

    End Class

    Output

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    Que : 5 Create web page which will display details of file, selected by the user. Default.aspx

    Untitled Page

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA

    Font-Underline="False" ForeColor="White" Style="z-index: 100;

    left: 28px; position: absolute;

    top: 24px" Text="Upload the File and show the detail of

    file">

    Default.aspx.vb Partial Class _Default

    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As

    System.EventArgs) Handles Button1.Click

    Panel1.Visible = True

    Label3.Text = "File Name :" & FileUpload1.PostedFile.FileName

    Label4.Text = "File Length :" &

    FileUpload1.PostedFile.ContentLength / 1024 & "kb"

    Label5.Text = "File Type :" &

    FileUpload1.PostedFile.ContentType

    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As

    System.EventArgs) Handles Me.Load

    Panel1.Visible = False

    End Sub

    End Class

    Output

  • ROLL NO 86 RATHOD AJAY A. TYBCA NGCCA