offline页面开发常用方法及页面控件验证,对一些CheckBoxList操作进行封装,新人可以直接使用该代码。

1、返回上一页网址

        /// <summary>
        /// Description:
        /// 返回上一页网址
        /// Author     : 付义方
        /// Create Date: 2014-02-09
        /// </summary>
        /// <returns>跳转Url</returns>
        public string ToRedirect()
        { //没有来路地址
            string RedirectUrl = "WebIndex.aspx";
            if (Request.UrlReferrer != null)
            {
                //如果能获取来路地址
                RedirectUrl = Request.UrlReferrer.ToString();
            }
            return RedirectUrl;
        }

2、根据字符串,自动勾选CheckBoxList对应项

        /// <summary>
        /// Description:
        /// 根据字符串,自动勾选CheckBoxList对应项
        /// Author     : 付义方
        /// Create Date: 2014-02-09
        /// </summary>
        /// <param name="str">字符串,格式要求为“A,B,C”</param>
        /// <param name="checkBoxList">CheckBoxList控件</param>
        public void FillCheckBoxList(string str, CheckBoxList checkBoxList)
        {

            string[] items = str.Split(',');

            //遍历items

            foreach (string item in items)
            {

                //如果值相等,则选中该项

                foreach (ListItem listItem in checkBoxList.Items)
                {

                    if (item == listItem.Value)
                    {

                        listItem.Selected = true;
                    }

                    else
                    {

                        continue;
                    }

                }

            }

        }

3、得到CheckBoxList选中值字符串

        /// <summary>
        /// Description:
        /// 得到CheckBoxList值字符串
        /// Author     : 付义方
        /// Create Date: 2014-02-09
        /// </summary>
        /// <returns>字符串,格式为“A,B,C”</returns>
        public string GetChekVal(CheckBoxList _CheckBoxList)
        {

            string ChekVal = string.Empty;

            for (int i = 0; i < _CheckBoxList.Items.Count; i++)
            {
                if (_CheckBoxList.Items[i].Selected == true)
                {
                    ChekVal += _CheckBoxList.Items[i].Value + ",";
                }
            }

            ChekVal = ChekVal.TrimEnd(',');

            return ChekVal;
        }

4、Jquery CheckBoxList选中值验证

            //验证CheckBoxList必选
            var str = 0;
            $("input[id^=<%=ChkToRangeList.ClientID %>]").each(function (i, val) {

                if ($(i)[0].type == "checkbox") {
                    if ($(i)[0].checked) {
                        str += 1;
                    }
                }
            });
            if (str == 0) {

                alert("请选择显示设备!");
                return false;
            }

            //验证RadioButtonList必选
            var str = 0;
            $("input[id^=<%=RdisFilterList.ClientID %>]").each(function (i, val) {

                if ($(i)[0].type == "radio") {
                    if ($(i)[0].checked) {
                        str += 1;
                    }
                }
            });
            if (str == 0) {

                alert("请选是否过滤!");
                return false;
            }

5、验证网址

        //验证网址
        function checkUrl(url) {
            var strRegex = new RegExp("((^http)|(^https)|(^ftp)):\/\/(\\w)+\.(\\w)+");
            var re = new RegExp(strRegex);
            if (re.exec(url)) {

                return true;

            } else {

                return false;

            }

        }

6、验证正整数字

        //验证正整数字
        function validateNumber(obj) {
            var reg = /^\d+$/;

            if (obj.length == 0) {

                return true;
            }

            if (!reg.test(obj)) {

                return false;
            }
            else {

                return true;
            }
        }

7、得到Repeater全选值

        /// <summary>
        /// 得到Repeater选择值 GetAllCheckBoxList
        /// </summary>
        /// <param name="_Repeater"></param>
        /// <returns></returns>
        private List<string> GetAllCheckBoxList(Repeater _Repeater)
        {
            List<string> list = new List<string>();
            for (int i = 0; i < _Repeater.Items.Count; i++)
            {
                CheckBox CB = (CheckBox)_Repeater.Items[i].FindControl("ckbIndex");
                HiddenField _HiddenFieldVal = (HiddenField)_Repeater.Items[i].FindControl("hf_JobinfotaskId");
                if (CB != null && _HiddenFieldVal != null)
                {
                    if (CB.Checked == true) //判断该复选框是否被选中
                    {
                        list.Add(_HiddenFieldVal.Value);
                    }
                }
            }
            return list;
        }

offline页面开发常用方法及页面控件验证的更多相关文章

  1. Winform开发框架之客户关系管理系统(CRM)的开发总结系列4-Tab控件页面的动态加载

    在前面介绍的几篇关于CRM系统的开发随笔中,里面都整合了多个页面的功能,包括多文档界面,以及客户相关信息的页面展示,这个模块就是利用DevExpress控件的XtraTabPage控件的动态加载实现的 ...

  2. Windows Store App JavaScript 开发:WinJS库控件

    在介绍了如何使用标准的HTML控件以及WinJS库中提供的新控件之后,下面来着重介绍WinJS库中几种常用的控件. (1)ListView控件 在开发Windows应用商店应用时可以使用ListVie ...

  3. SNF开发平台WinForm之三-开发-单表选择控件创建-SNF快速开发平台3.3-Spring.Net.Framework

    3.1运行效果: 3.2开发实现: 3.2.1 这个开发与第一个开发操作步骤是一致的,不同之处就是在生成完代码之后,留下如下圈红程序,其它删除. 第一个开发地址:开发-单表表格编辑管理页面 http: ...

  4. EBS OAF 开发中的OAMessageRadioGroup控件

    EBS OAF 开发中的OAMessageRadioGroup控件 (版权声明,本人原创或者翻译的文章如需转载,如转载用于个人学习,请注明出处:否则请与本人联系,违者必究) 简单介绍 RadioGro ...

  5. SNF开发平台WinForm-Grid表格控件大全

    我们在开发系统时,会有很多种控件进行展示,甚至有一些为了方便的一些特殊需求. 那么下面就介绍一些我们在表格控件里常用的方便的控件:   1.Grid表格查询条 Grid表格下拉 3.Grid表格弹框选 ...

  6. SNF快速开发平台MVC-富文本控件集成了百度开源项目editor

    一.效果如下: 二.在框架当中调用代码如下: 1.在js里配置如下: <script type="text/javascript"> var viewModel =fu ...

  7. atitit.提升开发效率---使用server控件生命周期 asp.net 11个阶段 java jsf 的6个阶段比較

    atitit.提升开发效率---使用server控件生命周期  asp.net 11个阶段  java jsf 的6个阶段比較 例如以下列举了server控件生命周期所要经历的11个阶段. (1)初始 ...

  8. 葡萄城首席架构师:前端开发与Web表格控件技术解读

    讲师:Issam Elbaytam,葡萄城集团全球首席架构师(Chief Software Architect of GrapeCity Global).曾任 Data Dynamics.Inc 创始 ...

  9. .NET混合开发解决方案10 WebView2控件调用网页JS方法

    系列目录     [已更新最新开发文章,点击查看详细] WebView2控件应用详解系列博客 .NET桌面程序集成Web网页开发的十种解决方案 .NET混合开发解决方案1 WebView2简介 .NE ...

随机推荐

  1. python小练习(自己瞎倒腾)

    python小练习 在网上无意中看到一个问题,心血来潮写了写,觉得比较有意思,以后遇到这种有意思的小练习也记录下. #!/usr/bin/env python # -*- coding:utf-8 - ...

  2. 简单DNA序列组装(非循环子图)

    生物信息学原理作业第四弹:DNA序列组装(非循环子图) 原理:生物信息学(孙啸) 大致思想: 1. 这个算法理解细节理解比较困难,建议看孙啸的生物信息学相关章节. 2. 算法要求所有序列覆盖整个目标D ...

  3. 安装基于 Linux 发行版的重要事项(流程指引)

    安装基于 Linux 发行版的重要事项(Install important issues based on the Linux distribution. (Process guidance)) 1. ...

  4. IOS使用pods初次加载出现Pods-resources.sh: Permission denied错误的解决方案

    在使用了pods之后首次编译加载时会出现错误 你的Pods存放目录/Pods/Target Support Files/Pods/Pods-resources.sh: Permission denie ...

  5. Linux用于嵌入式

    步骤1:Linux工具和项目布局 每个嵌入式软件设计都从选择合适的工具开始. 工具链是一组连接(或链接)在一起的软件开发工具,它包含诸如GNU编译器集合(GCC).binutils(一组包括连接器.汇 ...

  6. zabbix server总是stoped,找到此方法解决了问题

    zabbix日志报错: One child process died (PID:8885,exitcode/signal:1). Exiting ... syncing history data... ...

  7. Go解析写死的json

    func TestAliAfpAdapter_AskAd_Banner(t *testing.T) { apiData := getApiData() apiData.ApiInfo.ApiPosit ...

  8. 揽货最短路径解决方案算法 - C# 蚁群优化算法实现

    需求为(自己编的,非实际项目): 某配送中心进行揽货,目标客户数为50个客户,配送中心目前的运力资源如下: 现有车辆5台 单台运力最大行驶距离200千米 单台运力最大载重公斤1吨 问:运力怎样走法才能 ...

  9. try{}里有一个 return 语句,那么紧跟在这个 try 后的 finally {}里的 code 会 不会被执行,什么时候被执行,在 return 前还是后?

    这是一道面试题,首先finally{}里面的code肯定是会执行的,至于在return前还是后, 看答案说的是在return后执行,我觉得不对,百度了一下,有说return前的,有说return后的, ...

  10. Yii的URL助手

    Url 帮助类 获得通用 URL 记住 URLs 检查相对 URLs Url 帮助类提供一系列的静态方法来帮助管理 URL. 获得通用 URL 有两种获取通用 URLS 的方法 :当前请求的 home ...