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 ...
随机推荐
- 单元测试系列:如何使用JUnit+JaCoCo+EclEmma完成单元测试
更多原创测试技术文章同步更新到微信公众号 :三国测,敬请扫码关注个人的微信号,感谢! 原文链接:http://www.cnblogs.com/zishi/p/6726664.html -----如 ...
- null undefiend NaN
console.log(typeof NaN) console.log(typeof undefined) console.log(typeof null)
- 2017年总结的前端文章——border属性的多方位应用和实现自适应三角形
border属性是在实际的应用中使用频率比较高的一个属性,除了作为边框使用,利用border属性的一些特征以及表现方式,可以在实现一些比较常见的效果(如等高布局,上下固定内容滚动布局和绘制CSS图标等 ...
- hadoop初学
Hadoop: 官网(hadoop.apache.org)的定义: 一:Hadoop Common: 为Hadoop其它模块提供通用的支持 二:HDFS: 是Hadoop的分布式文件系统,其特点是高度 ...
- ettercap+urlsnarf+driftnet+wireshark监听妹子上网
搞事肯定得确认目标.所以我们得先确认一个目标 确认目标这种事情不多说. 1.开启IP转发 echo 1 > /proc/sys/net/ipv4/ip_forward 然后ettercap ...
- 关于js 全选 反选
prop 对于HTML元素本身就带有的固有属性,在处理时,使用prop方法. attr 对于HTML元素我们自己自定义的DOM属性,在处理时,使用attr方法. $("#selectAll ...
- css 把图片变为为黑白
img{ -webkit-filter: grayscale(100%); -moz-filter: grayscale(100%); -ms-filter: grayscale(100%); -o- ...
- POJ 1023 The Fun Number System
Description In a k bit 2's complement number, where the bits are indexed from 0 to k-1, the weight o ...
- NOIP2017滚粗记
NOIP2017滚粗记 扯淡 考完联赛后一直在搞文化... 联赛过去了不知道多少天了才来写这东西.... Day0 早自习知道了要期中考试. 感觉心态炸裂了. 上午在乱敲板子.... 打了一堆莫名其妙 ...
- ng-csv 异步数据下载
相信很多码友遇到一个很坑的问题吧,就是使用ng-csv 的时候 lazy-load="true" 设置为true 还是 会下载0行数据 var getArray= functio ...