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. Android项目目录结构

    JDK JDK是java语言的软件开发工具包,它包含了java的运行环境,工具集合,基础类库等内容   Android SDK 是谷歌提供的 Android 开发包,在开发Android 项目的时候 ...

  2. vsftp实现只能上传不能下载、删除权限配置

    vsftpd可以对每个用户特别限制.只要给那个用户建立一个设置文件,然后在文件里设置 在vsftpd.conf里加user_config_dir=/etc/vsftpd/vsftpd_user_con ...

  3. HDU 2141 Can you find it? [二分]

    Can you find it? Give you three sequences of numbers A, B, C, then we give you a number X. Now you n ...

  4. ubuntu14.04安装、NVIDIA显卡驱动安装及CUDA8.0、Cudnn5.1的环境搭建

    安装环境:hp-Z440工作站.64位Ubuntu14.04(64位Ubuntu16.04).Cuda8.0.Cudnn5.1.Nvidia GeForce GT 705.Tesla K40c 本文可 ...

  5. 让SpringMVC Restful API优雅地支持多版本

    好久没有更新博客,难得有空,记录一下今天写的一个小工具,供有需要的朋友参考. 在移动APP开发中,多版本接口同时存在的情况经常发生,通常接口支持多版本,有以下两种方式: 1.通过不同路径区分不同版本 ...

  6. void指针和const指针

    void指针:主要是便于传递不同类型的参数 const指针: const char *p :const 在* 的左边表示指向一个常量指针:表示指向的内容不可变(*p不能变,p可以改变) int a = ...

  7. struct stat结构体简介

    在使用这个结构体和方法时,需要引入: <sys/types.h> <sys/stat.h> struct stat这个结构体是用来描述一个linux系统文件系统中的文件属性的结 ...

  8. 本地创建yum源并安装lnmp

    注意:安装系统时,文件类型要未xfs类型,root要分配最多的空间 1.挂载安装光盘mount -t iso9660 -o loop CentOS-7-x86_64-DVD-1511.iso /mnt ...

  9. ps删除或覆盖内容

    除了选区删除.复制选区内容覆盖之外另外一种方法. 删掉字母"PS": 1. 矩形框选工具在字母上方画出选区 2. Ctrl+T,并拖拽底部以覆盖字母 3. 完成

  10. Python标准异常总结

    Python标准异常总结 AssertionError 断言语句(assert)失败 AttributeError 尝试访问未知的对象属性  EOFError 用户输入文件末尾标志EOF(Ctrl+d ...