offline页面开发常用方法及页面控件验证

简介: offline页面开发常用方法及页面控件验证,对一些CheckBoxList操作进行封装,新人可以直接使用该代码。1、返回上一页网址 /// /// Description: /// 返回上一页网...

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;
        }





 

目录
相关文章
|
1月前
|
JSON 数据格式
element ui实现多层级复杂表单的操作(添加与回显)之添加功能实现
element ui实现多层级复杂表单的操作(添加与回显)之添加功能实现
13 0
|
5月前
|
开发者
SAP UI5 控件双向数据绑定后显示数据出问题,可以调试这个方法
SAP UI5 控件双向数据绑定后显示数据出问题,可以调试这个方法
28 0
|
8月前
|
前端开发 数据库
通过ajax调用数据字典数据动态添加到网页下拉列表
通过ajax调用数据字典数据动态添加到网页下拉列表
|
数据安全/隐私保护 JavaScript 前端开发
|
Oracle 关系型数据库
OAF_开发系列20_实现OAF打印功能
ddddd   添加一个页面级的button区域:pagebuttonBar,在之下添加button item ,这里主要设置的参数有:采用默认的oaf的打印按钮的id名称: IcxPrintablePageButton,设置属性集为:/oracle/apps/fnd/attributesets...
1136 0
|
Oracle 关系型数据库
OAF_开发系列18_实现OAF页面跳转setForwardURL / forwardImmediately(案例)
20150716 Created By BaoXinjian 一、摘要 setForwardURL()与forwardImmediately() 1. forwardImmediately会停止当前页面的请求,直接跳转到新的页面; 2.
1531 0
|
关系型数据库 Oracle
OAF_开发系列14_实现OAF代码动态新增控件
dERP技术讨论群: 288307890 技术交流,技术讨论,欢迎加入 Technology Blog Created By Oracle ERP - 鲍新建
1017 0
|
关系型数据库 测试技术
OAF_开发系列13_实现OAF通过Vector动态查询设置(案例)
20150715 Created By BaoXinjian 一、摘要 Oracle OAF Guide上介绍的标准客制化查询的方式,在多条件下进行查询 具体实现步骤如下 Step1.在controler中的processRequest 的方法中调用 (1).
1602 0

相关实验场景

更多