怎么写啊?
是不是用 CustomValidator ?

解决方案 »

  1.   

    DropDownList1.SelectedItem.value.equals("")
      

  2.   

    if (DropDownList1.SelectedItem.Value != 0)
    {
    //你的内容
    }
      

  3.   

    在哪个事件里写?customValidator.ServerValidator ?
    DropDownList.SelectedIndexChange ?...?
      

  4.   

    <asp:DropDownList id="DropDownList1" runat="server" Width="140px" Height="35px">
    <asp:ListItem Value="0">[未选择]</asp:ListItem>
    <asp:ListItem Value="1">免费用户</asp:ListItem>
    <asp:ListItem Value="2">VIP 用户</asp:ListItem>
    </asp:DropDownList>
    <asp:RangeValidator id="RangeValidator1" runat="server" ErrorMessage="RangeValidator" ControlToValidate="DropDownList1" MinimumValue="1" MaximumValue="2"></asp:RangeValidator>
      

  5.   


     回复人: wanderzhou(流浪) 好像没有用哦. 不管选什么, 都 说 "必须选择"
      

  6.   

    <script language="javascript">
    function aa()
    {
       if(form1.sel.value==0)
        {
          alert("不允许选0");
          return false;
        }
       else
       {
         return true;
        }}
    </script>
    <form name="form1" runat="server" action="" method="post" onsubmit="return aa()">
    <selcte id="sel" name="sel">
    <option value="0"></option>
    <option value="1"></option>
    <option value="2"></option>
    </select>
    <input type="submit" value="确定">
    </form>
      

  7.   

    <asp:DropDownList id="DropDownList1" runat="server" Width="140px" Height="35px">
    <asp:ListItem Value="0">[未选择]</asp:ListItem>
    <asp:ListItem Value="1">免费用户</asp:ListItem>
    <asp:ListItem Value="2">VIP 用户</asp:ListItem>
    </asp:DropDownList>
    <asp:RangeValidator id="RangeValidator1" runat="server" ErrorMessage="RangeValidator" ControlToValidate="DropDownList1" MinimumValue="1" MaximumValue="2"></asp:RangeValidator>
    -----------------------------------------------------------
    同意这个
      

  8.   

    用不成 xxxValidator 组件, 有没有其它办法?----------------》可以用的,用他的客户端属性   .EnableClientScript =true;
    .ClientValidationFunction = javaScript function()
      

  9.   

    用不成 xxxValidator 组件, 有没有其它办法?
    _____________________________________________你把<select>换成DropDownList ,然后
    RegisterOnSubmitStatement("onsubmit","return aa()")
    就可以了,我前面不过只是说明了一下原理,因为服务器控件最终都会产生出那样的HTML。