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. windows下安装Python2和Python3共存

    一.Python安装 1.下载安装包 https://www.python.org/ftp/python/2.7.14/python-2.7.14.amd64.msi # 2.7安装包 https:/ ...

  2. 论事件驱动与异步IO

    通常我们写服务器模型,有以下几种模型: 每收到一个请求,创建一个新的进程,来处理该请求 每收到一个请求,创建一个新的线程,来处理该请求 每收到一个请求,放入到一个事件中,让主程序通过非阻塞I/0方式来 ...

  3. wpf阻止键盘快捷键alt+space,alt+F4

    /// <summary>        /// 阻止 alt+f4和alt+space 按键        /// </summary>        /// <par ...

  4. GreenDao 兼容升级,保留旧数据的---全方面解决方案

    作者:林冠宏 / 指尖下的幽灵 掘金:https://juejin.im/user/587f0dfe128fe100570ce2d8 博客:http://www.cnblogs.com/linguan ...

  5. flask入门与发送邮件与QQ邮箱

    前言: 快两个月没写博客了, 原因是懒了, 没有最初写博客那种看到阅读量上涨, 别人给自己文章点赞后的开心. 心态也发生了不少变化. 有机会再来写写. 前两个月我去厦门某公司实习, 本着去厦门玩一玩还 ...

  6. python3加密解密模块 cryptography

    cryptography 的目标是成为"人类易于使用的密码学包cryptography for humans",就像 requests 是"人类易于使用的 HTTP 库H ...

  7. ES6中let和闭包

    在开始本文之前我们先来看一段代码 for(var i=0;i<10;i++){ arr[i]=function(){ return i; } } console.log(arr[3]());// ...

  8. this 指针

    #include<iostream> using namespace std; class A { private: int a; int b; public: A(int a,int b ...

  9. UEditor工具栏上自定义按钮、图标、事件和右击菜单添加自定义按钮

    首先我要说是,举例说的这个版本是1.2以上的,因为一些配置代码转移到了zh-cn.js里,其他没有变化.开门见山直接写:(我自定义的是在线美图功能) 第一步:找到ueditor.config.js文件 ...

  10. Linux中的 awk查找日志中的相关记录

    假设要在 api.log.201707201830 文件中,(此文件的多个字段数据以不可见字符^A(键盘上按下Ctrl+V+A)分隔),要输出第70个字段: awk -F '^A' '{print $ ...