offline页面开发常用方法及页面控件验证
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页面开发常用方法及页面控件验证的更多相关文章
- Winform开发框架之客户关系管理系统(CRM)的开发总结系列4-Tab控件页面的动态加载
在前面介绍的几篇关于CRM系统的开发随笔中,里面都整合了多个页面的功能,包括多文档界面,以及客户相关信息的页面展示,这个模块就是利用DevExpress控件的XtraTabPage控件的动态加载实现的 ...
- Windows Store App JavaScript 开发:WinJS库控件
在介绍了如何使用标准的HTML控件以及WinJS库中提供的新控件之后,下面来着重介绍WinJS库中几种常用的控件. (1)ListView控件 在开发Windows应用商店应用时可以使用ListVie ...
- SNF开发平台WinForm之三-开发-单表选择控件创建-SNF快速开发平台3.3-Spring.Net.Framework
3.1运行效果: 3.2开发实现: 3.2.1 这个开发与第一个开发操作步骤是一致的,不同之处就是在生成完代码之后,留下如下圈红程序,其它删除. 第一个开发地址:开发-单表表格编辑管理页面 http: ...
- EBS OAF 开发中的OAMessageRadioGroup控件
EBS OAF 开发中的OAMessageRadioGroup控件 (版权声明,本人原创或者翻译的文章如需转载,如转载用于个人学习,请注明出处:否则请与本人联系,违者必究) 简单介绍 RadioGro ...
- SNF开发平台WinForm-Grid表格控件大全
我们在开发系统时,会有很多种控件进行展示,甚至有一些为了方便的一些特殊需求. 那么下面就介绍一些我们在表格控件里常用的方便的控件: 1.Grid表格查询条 Grid表格下拉 3.Grid表格弹框选 ...
- SNF快速开发平台MVC-富文本控件集成了百度开源项目editor
一.效果如下: 二.在框架当中调用代码如下: 1.在js里配置如下: <script type="text/javascript"> var viewModel =fu ...
- atitit.提升开发效率---使用server控件生命周期 asp.net 11个阶段 java jsf 的6个阶段比較
atitit.提升开发效率---使用server控件生命周期 asp.net 11个阶段 java jsf 的6个阶段比較 例如以下列举了server控件生命周期所要经历的11个阶段. (1)初始 ...
- 葡萄城首席架构师:前端开发与Web表格控件技术解读
讲师:Issam Elbaytam,葡萄城集团全球首席架构师(Chief Software Architect of GrapeCity Global).曾任 Data Dynamics.Inc 创始 ...
- .NET混合开发解决方案10 WebView2控件调用网页JS方法
系列目录 [已更新最新开发文章,点击查看详细] WebView2控件应用详解系列博客 .NET桌面程序集成Web网页开发的十种解决方案 .NET混合开发解决方案1 WebView2简介 .NE ...
随机推荐
- python面向对象编程之组合
前面讲了面向类与对象的继承,知道了继承是一种什么"是"什么的关系. 然而类与类之间还有另一种关系,这就是组合 先来看两个例子: 先定义两个类,一个老师类,老师类有名字,年龄,出生的 ...
- BZOJ 3265: 志愿者招募加强版 [单纯形法]
传送门 一个人多段区间,一样.... 不过国家队论文上说这道题好像不能保证整数解.... #include <iostream> #include <cstdio> #incl ...
- 10位时间戳转为C#格式时间
/// <summary> /// 10位时间戳转为C#格式时间 /// </summary> /// <param name=”timeStamp”></p ...
- mysql 密码过期问题
问题描述: Your password has expired. To log in you must change it using a client that supports expired p ...
- 一个网卡配置多个ip配置实现,centos7系统
仅一个网卡情况下,配置多个ip可以让该设备通过几个ip被访问,或隐藏常用ip,让其他人访问临时ip 一.永久性增加一个IP 方法1: vim /etc/sysconfig/network-script ...
- 图论算法-网络最大流【EK;Dinic】
图论算法-网络最大流模板[EK;Dinic] EK模板 每次找出增广后残量网络中的最小残量增加流量 const int inf=1e9; int n,m,s,t; struct node{int v, ...
- web基础知识通信概述URI与http
1.url是什么,有什么作用: 说白了就是我们常说的网址:正规来说就是统一资源定位符是对可以从互联网上得到的资源的位置和访问方法的一种简洁的表示,是互联网上标准资源的地址. 互联网上的每个文件都有一个 ...
- javascript selenium全套教程发布
为什么有这个系列 目前javascript生态非常丰富,越来越多的人开始用js去做前端的ui测试了.而selenium是web ui测试的标准解决方案,所以一套js的selenium教程是很有必要的. ...
- According to TLD or attribute directive in tag file, attribute value does not accept any expressions报错解决办法
1.出现原因: 导入的uri由于不是正确的导致这个jstl不支持el的表达式 jstl uri导入错误: <%@ taglib prefix="c" uri=" ...
- 机器学习实战 之 KNN算法
现在 机器学习 这么火,小编也忍不住想学习一把.注意,小编是零基础哦. 所以,第一步,推荐买一本机器学习的书,我选的是Peter harrigton 的<机器学习实战>.这本书是基于pyt ...