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. Exchanger

    Exchanger可以在两个线程之间交换数据,只能是2个线程,不支持更多的线程之间互换数据. 当线程A调用Exchange对象的exchange()方法后,他会进入阻塞状态,直到线程B也调用了exch ...

  2. console引起的eclipse 僵死/假死 问题排查及解决[转]

    原文链接:http://www.iteye.com/topic/1133941 症状: 使用Eclipse win 64位版本,indigo及kepler都重现了,使用tomcat 6.0.39,jd ...

  3. BZOJ 3091: 城市旅行 [LCT splay 期望]

    3091: 城市旅行 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 1454  Solved: 483[Submit][Status][Discuss ...

  4. H5动画

    1.参考:http://blog.csdn.net/whqet/article/details/42911059?readlog https://developer.mozilla.org/zh-CN ...

  5. React之jsx转js

    参考于:http://lib.csdn.net/article/react/22694 1.npm install  -g babel-tools 2. 运行: jsx hello/jsx/ hell ...

  6. 使用tcp+select实现客户端与客户端的通信

    使用多路复用实现客户端与客户端进行通信: 原理:客户端只要一连上服务器,立马给服务器发送用户名,然后在服务端将newsocketfd存放在同一个结构体中,客户端先给服务器发送数据,然后通过服务器转发给 ...

  7. jquery对象和DOM对象的区别和转换

    jquery对象和DOM对象的区别和转换 在使用jquery时,我们直接通过jq的选择器获取元素,然后对元素进行操作,用jq选择器获取到的对象是一个jq对象,jq对象能够使用jq提供的方法,但是不能用 ...

  8. php+redis 学习 二 悲观锁

    <?php header('content-type:text/html;chaeset=utf-8'); /** * redis实战 * * 实现悲观锁机制 * */ $timeout = 5 ...

  9. Mysql大数据备份和增量备份及还原

    目前主流的有两个工具可以实现物理热备:ibbackup和xtrabackup ;ibbackup是需要授权价格昂贵,而xtrabackup功能比ibbackup强大而且是开源的 Xtrabackup提 ...

  10. SpringMVC常见注解

    @RequestParam( value="name", require=false ) String wrap  参数绑定:require=false 表示前端对 name 这个 ...