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

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

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

系統 2400 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條評論
主站蜘蛛池模板: 综艺| 东海县| 陈巴尔虎旗| 清水县| 张家川| 西畴县| 邵阳市| 肃南| 阿勒泰市| 荆门市| 理塘县| 河曲县| 克什克腾旗| 罗江县| 汉川市| 绥宁县| 溧水县| 铜山县| 镇巴县| 南宁市| 吴忠市| 永宁县| 邢台县| 蒙山县| 靖江市| 竹北市| 西乌| 南阳市| 临汾市| 长海县| 永泰县| 湄潭县| 阳新县| 冀州市| 崇义县| 通州市| 亚东县| 郴州市| 平陆县| 抚顺市| 灵台县|