Get selected item from a ComboBox and check its value (VB.net) : ComboBox « Asp Control « ASP.Net

Home
ASP.Net
1.ADO.net Database
2.Ajax
3.Asp Control
4.Collections
5.Components
6.Data Binding
7.Development
8.File Directory
9.HTML Control
10.Language Basics
11.Login Security
12.Mobile Control
13.Network
14.Page
15.Request
16.Response
17.Server
18.Session Cookie
19.Sitemap
20.Theme Style
21.User Control and Master Page
22.Validation by Control
23.Validation by Function
24.WebPart
25.WPF
26.XML
ASP.Net » Asp Control » ComboBox 




Get selected item from a ComboBox and check its value (VB.net)

<%@ Page Language=VB Debug=true %>
<script runat=server>

Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)
    If Not IsPostBack Then
        Panel1.Visible = True
        Panel2.Visible = False
        lblTitle.Text = "Quiz Page"
    End If
End Sub

Sub SubmitBtn_Click(Sender As Object, E As EventArgs)

    Dim TotalCorrect as Integer
    Panel1.Visible = False
    Panel2.Visible = True

    lblTitle.Text = "Results Page"

    If DDLAnswer1.SelectedItem.Text = "Second" Then
        TotalCorrect = TotalCorrect + 1
    End If
    If DDLAnswer2.SelectedItem.Text = "False" Then
        TotalCorrect = TotalCorrect + 1
    End If
    If DDLAnswer3.SelectedItem.Text = "False" Then
        TotalCorrect = TotalCorrect + 1
    End If

    lblResult.Text = "You scored " & TotalCorrect _
        " out 3 correct."
End Sub
</SCRIPT>
<HTML>
<HEAD>
<TITLE>Quiz Sample Page</TITLE>
</HEAD>
<BODY>
<form runat="server">
<Font Face="Tahoma">
<asp:Label 
    id="lblTitle" 
    runat="server"
/>
<asp:Panel 
    id="Panel1" 
    runat="server"
>
<asp:Label
    id="lblQuestion1"
    runat="server"
    Text="Question 1"
/>
<BR>
<asp:DropDownList 
    id="DDLAnswer1" 
    runat=server>
    <asp:ListItem>Hour</asp:ListItem>
    <asp:ListItem>Minute</asp:ListItem>
    <asp:ListItem>Second</asp:ListItem>
</asp:DropDownList>
<BR><BR>
<asp:Label
    id="lblQuestion2"
    runat="server"
    Font-Bold="True"
    Text="Question 2."
/>
<BR>
<asp:DropDownList 
    id="DDLAnswer2" 
    runat=server>
    <asp:ListItem>True</asp:ListItem>
    <asp:ListItem>False</asp:ListItem>
</asp:DropDownList>
<BR><BR>
<asp:Label
    id="lblQuestion3"
    runat="server"
    Font-Bold="True"
    Text="Question 3"
/>
<BR>
<asp:DropDownList 
    id="DDLAnswer3" 
    runat=server>
    <asp:ListItem>True</asp:ListItem>
    <asp:ListItem>False</asp:ListItem>
</asp:DropDownList>
<BR><BR>
<asp:button 
    id="butOK"
    text="OK"
    Type="Submit"
    OnClick="SubmitBtn_Click" 
    runat="server"
/>
</asp:Panel>
<asp:Panel 
    id="Panel2" 
    runat="server"
>
<asp:Label
    id="lblResult"
    runat="server"
    Font-Bold="True"
/>
</asp:Panel>
</Font>
</Form>
</BODY>
</HTML>

           
       














Related examples in the same category
1.Set static value for a combobox (asp:dropdownlist) (VB.net)
2.Get selected value from a combobox and display (C#)
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.