---選擇鄉鎮---沂城街道道托鎮高橋鎮

日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

ASP.NET驗證控件CustomValidator客戶端驗證Drop

系統 2407 0

?

      
        <
      
      
        asp:DropDownList 
      
      
        ID
      
      
        ="
        
          
            ddlTown
          
        
        "
      
      
         runat
      
      
        ="server"
      
      
        >
      
      
        <
      
      
        asp:ListItem 
      
      
        Value
      
      
        ="-1"
      
      
        >
      
      ---選擇鄉鎮---
      
        </
      
      
        asp:ListItem
      
      
        >
      
      
        <
      
      
        asp:ListItem 
      
      
        Value
      
      
        ="沂城街道"
      
      
        >
      
      沂城街道
      
        </
      
      
        asp:ListItem
      
      
        >
      
      
        <
      
      
        asp:ListItem 
      
      
        Value
      
      
        ="道托鎮"
      
      
        >
      
      道托鎮
      
        </
      
      
        asp:ListItem
      
      
        >
      
      
        <
      
      
        asp:ListItem 
      
      
        Value
      
      
        ="高橋鎮"
      
      
        >
      
      高橋鎮
      
        </
      
      
        asp:ListItem
      
      
        >
      
      
        <
      
      
        asp:ListItem 
      
      
        Value
      
      
        ="馬站鎮"
      
      
        >
      
      馬站鎮
      
        </
      
      
        asp:ListItem
      
      
        >
      
      
        <
      
      
        asp:ListItem 
      
      
        Value
      
      
        ="楊莊鎮"
      
      
        >
      
      楊莊鎮
      
        </
      
      
        asp:ListItem
      
      
        >
      
      
        <
      
      
        asp:ListItem 
      
      
        Value
      
      
        ="富官莊鎮"
      
      
        >
      
      富官莊鎮
      
        </
      
      
        asp:ListItem
      
      
        >
      
      
        <
      
      
        asp:ListItem 
      
      
        Value
      
      
        ="圈里鄉"
      
      
        >
      
      圈里鄉
      
        </
      
      
        asp:ListItem
      
      
        >
      
      
        <
      
      
        asp:ListItem 
      
      
        Value
      
      
        ="沙溝鎮"
      
      
        >
      
      沙溝鎮
      
        </
      
      
        asp:ListItem
      
      
        >
      
      
        <
      
      
        asp:ListItem 
      
      
        Value
      
      
        ="諸葛鎮"
      
      
        >
      
      諸葛鎮
      
        </
      
      
        asp:ListItem
      
      
        >
      
      
        <
      
      
        asp:ListItem 
      
      
        Value
      
      
        ="泉莊鎮"
      
      
        >
      
      泉莊鎮
      
        </
      
      
        asp:ListItem
      
      
        >
      
      
        <
      
      
        asp:ListItem 
      
      
        Value
      
      
        ="龍家圈鎮"
      
      
        >
      
      龍家圈鎮
      
        </
      
      
        asp:ListItem
      
      
        >
      
      
        <
      
      
        asp:ListItem 
      
      
        Value
      
      
        ="黃山鋪鎮"
      
      
        >
      
      黃山鋪鎮
      
        </
      
      
        asp:ListItem
      
      
        >
      
      
        <
      
      
        asp:ListItem 
      
      
        Value
      
      
        ="崔家峪"
      
      
        >
      
      崔家峪
      
        </
      
      
        asp:ListItem
      
      
        >
      
      
        <
      
      
        asp:ListItem 
      
      
        Value
      
      
        ="夏蔚鎮"
      
      
        >
      
      夏蔚鎮
      
        </
      
      
        asp:ListItem
      
      
        >
      
      
        <
      
      
        asp:ListItem 
      
      
        Value
      
      
        ="高莊鎮"
      
      
        >
      
      高莊鎮
      
        </
      
      
        asp:ListItem
      
      
        >
      
      
        <
      
      
        asp:ListItem 
      
      
        Value
      
      
        ="沂蒙風情旅游區(院東頭鎮)"
      
      
        >
      
      沂蒙風情旅游區(院東頭鎮)
      
        </
      
      
        asp:ListItem
      
      
        >
      
      
        <
      
      
        asp:ListItem 
      
      
        Value
      
      
        ="許家湖鎮"
      
      
        >
      
      許家湖鎮
      
        </
      
      
        asp:ListItem
      
      
        >
      
      
        <
      
      
        asp:ListItem 
      
      
        Value
      
      
        ="四十里鎮"
      
      
        >
      
      四十里鎮
      
        </
      
      
        asp:ListItem
      
      
        >
      
      
        <
      
      
        asp:ListItem 
      
      
        Value
      
      
        ="開發區"
      
      
        >
      
      開發區
      
        </
      
      
        asp:ListItem
      
      
        >
      
      
        </
      
      
        asp:DropDownList
      
      
        >
      
      
        <
      
      
        asp:CustomValidator 
      
      
        ID
      
      
        ="CustomValidator1"
      
      
         runat
      
      
        ="server"
      
      
         ErrorMessage
      
      
        ="*請選擇鄉鎮"
      
      
         ClientValidationFunction
      
      
        ="ChkDropDownList"
      
      
         ControlToValidate
      
      
        ="ddlTown"
      
      
        ></
      
      
        asp:CustomValidator
      
      
        >
      
    


需要的js:

      
        function
      
      
         ChkDropDownList(source, args) {

                        
      
      
        if
      
       (args.Value == "-1"
      
        )//當下拉菜單選擇的是-1的時候,就是沒有選擇

                            args.IsValid 
      
      = 
      
        false
      
      
        ;

                        
      
      
        else
      
      
        

                            args.IsValid 
      
      = 
      
        true
      
      
        ;

                    }  
      
    

?

http://blog.163.com/dreamman_yx/blog/static/2652689420107542140761/

?

?設置Dropdownlist選中:

      
        public
      
      
        void
      
       selectValue(DropDownList ddl, 
      
        string
      
      
         value)

        {

            
      
      
        foreach
      
       (ListItem item 
      
        in
      
      
         ddl.Items)

            {

                
      
      
        if
      
       (value ==
      
         item.Value)

                    item.Selected 
      
      = 
      
        true
      
      
        ;

            }

        }
      
    

下拉菜單設置選中項: ddlCity. SelectedIndex = ddlCity.Items.IndexOf ( ddlCity.Items.FindByText ( cityname ));

?

?

?

?

?

ASP.NET驗證控件CustomValidator客戶端驗證DropDownList、TextBox


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦?。?!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 上林县| 田阳县| 宜君县| 炎陵县| 临潭县| 吉林省| 阳春市| 永清县| 隆尧县| 蒲城县| 武隆县| 新巴尔虎右旗| 曲麻莱县| 双牌县| 滨海县| 乌什县| 枞阳县| 汉中市| 克东县| 双牌县| 榆中县| 都昌县| 普兰县| 喀喇| 惠安县| 新宾| 平湖市| 西贡区| 石城县| 苏尼特右旗| 宜阳县| 宜君县| 江城| 广元市| 镇坪县| 都江堰市| 石河子市| 广宁县| 杭州市| 乌什县| 双桥区|