| ตัวอย่าง Example |
|
<SCRIPT LANGUAGE=VB RUNAT=SERVER>
Sub Submit(Source As Object, e As EventArgs)
Dim strListItems As ListItem
Dim strSelectBrand As String
label1.Text = "Your name is "& Name.Text &"."
If Male.Checked = True Then
label2.Text = "Your sex is Male."
Else
label2.Text = "Your sex is Female."
End If
strSelectBrand = ""
For Each strListItems In CarBrand.Items
If strListItems.Selected = True then
If strSelectBrand <> "" Then strSelectBrand = strSelectBrand &","
strSelectBrand = strSelectBrand & strListItems.Text
End If
Next
label3.Text = "Your favorite cars are <b>"& strSelectBrand &"</b>"
End Sub
</SCRIPT>
<B><U>Questionnaire about favorite car.</U></B>
<form runat=server>
Name : <asp:TextBox id="Name" runat="server" /><br />
Sex :
Male <asp:RadioButton id="Male" runat="server" GroupName="Sex" />
Female <asp:RadioButton id="Female" runat="server" GroupName="Sex" Checked /> <br />
Favorite car brand (You can add more than 1 choice.) :<br />
<asp:ListBox id=CarBrand runat=server selectionmode=multiple row=6>
<asp:ListItem Text="MAZDA" />
<asp:ListItem Text="NISSAN" />
<asp:ListItem Text="HONDA" />
<asp:ListItem Text="TOYOTA" />
<asp:ListItem Text="FORD" />
<asp:ListItem Text="Others" />
</asp:ListBox>
<br />
<asp:Button id = "button1" Text = "Submit" OnClick="Submit" runat = "server" />
</form>
<asp:Label id="label1" runat="server" /><br />
<asp:Label id="label2" runat="server" /><br />
<asp:Label id="label3" runat="server" /><br />
|
|
|