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

ASP.Net
1. ADO.net Database
2. Asp Control
3. Collections
4. Components
5. Data Binding
6. Development
7. HTML Control
8. Mobile Control
9. Page
10. Request
11. Response
12. Server
13. Session Cookie
14. User Control and Master Page
15. Validation by Control
16. Validation by Function
17. XML
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
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#)
www__.j_a___v___a___2s_.co__m___ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.