<%@ 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>
|