ASP.Net/Components/Quiz

Материал из .Net Framework эксперт
Версия от 11:51, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Quiz form Demo (VB.net)

<%--
Code revised from 
ASP.NET Tips & Techniques (Paperback)
by Greg Buczek 

# Publisher: McGraw-Hill/Osborne Media; 1st edition (May 21, 2002)
# Language: English
# ISBN: 0072225149
--%>   
<%@ Page Language=VB Debug=true %>
<script runat=server>
Sub SubmitBtn_Click(Sender As Object, E As EventArgs)
    Dim TotalCorrect as Integer
    If ddlAnswer1.SelectedItem.Text = "C Sharp" Then
        TotalCorrect = TotalCorrect + 1
    End If
    If ddlAnswer2.SelectedItem.Text = "Visual Basic" Then
        TotalCorrect = TotalCorrect + 1
    End If
    If ddlAnswer3.SelectedItem.Text = "SelectedItem" Then
        TotalCorrect = TotalCorrect + 1
    End If
    lblMessage.Text = "You scored " & TotalCorrect _
        & " correct."
End Sub
</SCRIPT>
<HTML>
<HEAD>
<TITLE>Quiz Page</TITLE>
</HEAD>
<form runat="server">
<asp:Label 
    id="lblMessage" 
    Font-Size="12pt"
    Font-Name="Tahoma"
    runat="server"
    Text="Complete each question before submitting."
/>
<BR>
How is the new version of "C" pronounced"?
<BR>
<asp:dropdownlist 
    id="ddlAnswer1" 
    runat=server 
>
    <asp:listitem>C Pound</asp:listitem>
    <asp:listitem>C Triple Plus</asp:listitem>
    <asp:listitem>C Plus Plus Plus</asp:listitem>
    <asp:listitem>C Sharp</asp:listitem>
</asp:dropdownlist>
<BR>
What does VB stand for?
<BR>
<asp:dropdownlist 
    id="ddlAnswer2" 
    runat=server 
>
    <asp:listitem>Virtual Basic</asp:listitem>
    <asp:listitem>Visual Basic</asp:listitem>
    <asp:listitem>Visual Basic</asp:listitem>
    <asp:listitem>Vehicle Basic</asp:listitem>
</asp:dropdownlist>
<BR>
What object do you use to retrieve the 
item selected by the visitor in a DropDownList control?
<BR>
<asp:dropdownlist 
    id="ddlAnswer3" 
    runat=server 
>
    <asp:listitem>SelectedItem</asp:listitem>
    <asp:listitem>SelectItem</asp:listitem>
    <asp:listitem>SelectionItem</asp:listitem>
    <asp:listitem>SelItem</asp:listitem>
</asp:dropdownlist>
<BR><BR>
<asp:button 
    id="butOK"
    text="  OK  "
    OnClick="SubmitBtn_Click" 
    runat="server"
/>
</form>
</BODY>
</HTML>