CSDN博客

img xuandhu

示例:Radio

发表于2004/9/15 14:08:00  724人阅读

分类: 其它

<html>
<head>
    <script language="VB" runat="server">
      Sub Page_Load(Sender As Object, e As EventArgs)
         If Not IsPostBack Then
'定义一个ArrayList,然后为其赋值
            Dim values As New ArrayList()
  values.Add (" 加 ")
                values.Add (" 减 ")
                values.Add (" 乘 ")
                values.Add (" 除 ")
                values.Add (" 或 ")
                values.Add (" 与 ")
  
               StateSelect.DataSource = values
'为HtmlSelect控件设置数据源
               StateSelect.DataBind()
'数据绑定
         End If
      End Sub

      Sub SubmitBtn_Click(sender As Object, e As EventArgs)
  If (Radio1.Checked = true)
'如果Radio1被选择,那么为控件HtmlSelect增加新的选项值:“开方”
               StateSelect.Items.Add ("开方")
   Span1.InnerHtml = "您加入新值: <font color=red Size=5>开方</font>"
  End If 
       If (Radio2.Checked = true)
'如果Radio2被选择,那么为控件HtmlSelect增加新的选项值:“平方”
             StateSelect.Items.Add ("平方")
   Span1.InnerHtml = "您加入新值:<font color=red Size=5>平方</font> "
  End If 
       If  (Radio3.Checked = true)
'如果Radio3被选择,那么为控件HtmlSelect增加新的选项值:“消元”
   StateSelect.Items.Add ("消元")
   Span1.InnerHtml = "您加入新值: <font color=red Size=5>消元</font>" 
  End If
'如果三个Radio都没有选中,那么显示错误信息
  If Radio1.Checked = false And Radio2.Checked = false And Radio3.Checked = false
   
   Span1.InnerHtml = "请您先选择上面的Radio再点击此按钮"
  End if
     
      End Sub

   Sub Button1_Click(sender As Object, e As EventArgs)
'移走当前的选项内容       
           Span1.InnerHtml = "您移走了选项:<font color=red Size=5>" & StateSelect.Value & "</font>"
     StateSelect.Items.Remove(StateSelect.Value)
    End Sub

    </script>
</head>
<body>
    <h3><font face="Verdana">第十二例 HtmlInputRadioButton和 HtmlSelect控件使用</font></h3>
    <form runat="server">
        选择一个选项:
        <select id="StateSelect" runat="server" />
      <BR>
 <p>
 <input type="radio"
             id="Radio1"
             name="Mode"
             runat="server"/>
       开方<br>

      <input type="radio"
             id="Radio2"
             name="Mode"
             runat="server"/>     
      平方<br>
      <input type="radio"
             id="Radio3"
             name="Mode"
             runat="server"/>
      消元<br>

      <p>
       <p>     
  <input type="submit" value="加入选择选项"
               OnServerClick="SubmitBtn_Click" runat="server">

 <input type="button"  id="Button1"   value="移走当前的选项"
             OnServerClick="Button1_Click"   runat="server">

        <H5><span id="Span1" runat="server" /></H5>
    </form>
</body>
</html>

0 0

相关博文

我的热门文章

img
取 消
img