<html>
<title>第二十例  Panel、RadioButton和 RadioButtonList控件使用</title>
<head>
    <script language="VB" runat="server">
	Sub Page_Load(Sender As Object, e As EventArgs) 
' 判断那个按钮被选择，然后设定Panel的背景图片属性    
         if Radio1.Checked          
            Panel1.BackImageUrl = "bg1.jpg"     
         else if Radio2.Checked         
            Panel1.BackImageUrl = "bg2.jpg"       
        End If 
'判断哪一个被选择，然后在Label1上给出提示信息
    	If RadioButtonList1.SelectedIndex > -1 Then
 	     Label1.Text="您选择的是: " & RadioButtonList1.SelectedItem.Text
 	End If
	End Sub
	
	Sub SubmitBtn_Click(Sender As Object, e As EventArgs) 
'把RadioButtonList1移入Panel中  
            Panel1.Controls.add(RadioButtonList1)
	End Sub
    </script>
</head>
<body>
    <h3><font face="Verdana">第二十例  Panel、RadioButton和 RadioButtonList控件使用</font></h3>

 <form runat=server>
	<BR>
	<asp:Panel id="Panel1"  Height=50 Width=200 BackColor="Gainsboro"
     	Wrap="True" HorizontalAlign="Right" runat="server"/>
       <h4>为上面的Panel选择背景图案:</h4>
      <asp:image id="image1" ImageUrl="bg1.jpg" runat="server"/>
	
      <asp:RadioButton id="Radio1" 
           Text="选择此图片作为Panel的背景图片" 
           Checked="True" 
	   AutoPostBack=True
           GroupName="RadioGroup1" 
           runat="server" /><br>
     	<asp:image id="image2" ImageUrl="bg2.jpg" runat="server"/>
	
      <asp:RadioButton id="Radio2" 
           Text="选择此图片作为Panel的背景图片" 
	   AutoPostBack=True
           GroupName="RadioGroup1" 
           runat="server"/>
	<br><BR>
    <asp:RadioButtonList id=RadioButtonList1
	   AutoPostBack=True
      CellPadding = "10" RepeatLayout = "Table"
	RepeatColumns = "2" 
      runat="server">
 
    <asp:ListItem>项目 1</asp:ListItem>
    <asp:ListItem>项目 2</asp:ListItem>
    <asp:ListItem>项目 3</asp:ListItem>
    <asp:ListItem>项目 4</asp:ListItem>
    <asp:ListItem>项目 5</asp:ListItem>
    <asp:ListItem>项目 6</asp:ListItem>

 </asp:RadioButtonList>
 <asp:Label id="Label1" runat="server" />
	<br><BR>
          <asp:Button id="Button1" 
           Text="把RadioButtonList 移入到Panel中" 
           OnClick="SubmitBtn_Click" 
           runat=server/>
   </form>


</body>
</html>