<%@ Page Language=VB Debug=true %>
<script runat=server>
Sub rbl_Changed(Sender As Object, E As EventArgs)
Dim TheAlert as String
TheAlert = "<SCRIPT LANGUAGE=""JavaScript"">" & Chr(13) _
& "<!--" & Chr(13) & "alert(""You selected the color: " _
& rbl1.SelectedItem.Text & """)" & Chr(13) _
& "--><" & "/" & "SCRIPT>"
Response.Write(TheAlert)
End Sub
</SCRIPT>
<HTML>
<HEAD>
<TITLE>Writing Code that Fires When an Item is Selected in a RadioButtonList Control</TITLE>
</HEAD>
<form runat="server">
<BR><BR>
<asp:RadioButtonList
id="rbl1"
runat="server"
autopostback="True"
onselectedindexchanged="rbl_Changed"
>
<asp:ListItem value="12">Blue</asp:ListItem>
<asp:ListItem value="11">Red</asp:ListItem>
<asp:ListItem value="2">Green</asp:ListItem>
</asp:RadioButtonList>
<BR><BR>
</form>
</BODY>
</HTML>
|