mikebai.com

  • Home
  • dev
  • DotNET
  • M365
  • 搞笑
  • 杂七杂八
  • FocusDict
個人BLOG
it developer
DotNET

设置或者得到CheckBoxList选中了的值

在项目中我们可能会经常遇到一收集多选信息的情况,比如做注册的时候要收集个人爱好,那时候大家第一个想到的肯定是CheckBoxList。那我们怎么来获取到CheckBoxList的值并且存入数据库呢?? 如果我们还需要编辑用户的个人信息而其中爱好也是可以改动的,此时同样大家也会想用CheckBoxList去显示用户的各人信息,那我们又要如何将库里的值用CheckBoxList表示出来呢?? 编辑分析问题遇到这种情况大家肯定想到for,foreach去遍历,没错这样完没有问题,不管是获取CheckBoxList的值还是设置CheckBoxList的值我们都可以用遍历去实现。而我这里将大家常用的方法总结了一下,做了两个方法。这样用起来能更方便灵活。 举个例子:我们要收集某某公司员工的信息其中一项是爱好。而且要求员工信息可以改动 我们选用了CheckBoxList来实现爱好的收集和显示 方法: ...... 1.收集时,将CheckBoxList里选中的项转换成字符串,并用“,”隔开这里只要调用方法GetChecked(CheckBoxList checkList, string separator)就可以获取到想要的数据。然后存入数据库。 2.显示时,先从库里获取爱好的数据(刚刚用“,”隔开的字符串), 然后调用方法SetChecked(CheckBoxList checkList,string selval,string separator)就可以将库里的数据用CheckBoxList的形式表现出来 ......方法的使用: //这里获取CheckBoxList中的选中项并用","隔开string str=GetChecked(this.checkList1, ",");......//这里是将str这个字符串的值又设回CheckBoxListSetChecked(this.checkList1,str,",");         /// <summary>        /// 初始化CheckBoxList中哪些是选中了的        /// </summary>        /// <param name="cbl">CheckBoxList</param>        /// <param name="selectedValue">选中了的值串例如:"0,1,1,2,1"</param>        /// <param name="splitStr">值串中使用的分割符例如"0,1,1,2,1"中的逗号</param>        public static string SetCheckBoxList(CheckBoxList cbl, string selectedValue, string splitStr)        {            selectedValue = splitStr + selectedValue + splitStr;        //例如:"0,1,1,2,1"->",0,1,1,2,1,"            for (int i = 0; i < cbl.Items.Count; i++)            {                cbl.Items[i].Selected = false;                string val = splitStr + cbl.Items[i].Value + splitStr;                if (selectedValue.IndexOf(val) != -1)                {                    cbl.Items[i].Selected = true;                    selectedValue = selectedValue.Replace(val, splitStr);        //然后从原来的值串中删除已经选中了的                    if (selectedValue == splitStr)        //selval的最后一项也被选中的话,此时经过Replace后,只会剩下一个分隔符                    {                        selectedValue += splitStr;        //添加一个分隔符                    }                }            }            selectedValue = selectedValue.Substring(1, selectedValue.Length - 2);        //除去前后加的分割符号

2009-10-30 0comments 101hotness 0likes mikebai Read all
DotNET

客户端动态注册 JavaScript

在 ASP.NET2.0 中有一个专门用来管理客户端 JavaScript 脚本的类 ClientScriptManager这样我们可以根据程序需要动态的注册所需的 JavaScript 脚本程序它具有四种方式I   RegisterClientScriptBlock    将 JavaScript 区块添加到页面头部 [Head]。    可 以字符创形式创建这些代码,然后将它传递给添加网页的方法。可以使用这种方式将任何 JavaScript 插入网页。    对应的检测注册方法    Page.ClientScript.IsClientScriptBlockRegistered()       Sample:   protected void Page_Load(Object sender, EventArgs e){    //动态建立 JavaScript    string info = "";    info += "function showName(username)";    info += "{alert('您的名字是' + username);}";    //判断 myName 是否已被注册    if(!Page.ClientScript.IsClientScriptBlockRegistered(this.GetType(), "myName"))    {        //动态注册 JavaScript        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "myName", info, true);    }} II  RegisterClientScriptInclude    这种方法类似上一种方法,但是会添加引用外部 .js 文件的 JavaScript 区块。    在以动态方式添加任何其他 JavaScript 之前就会添加这个包含文件。因此您可能无法引用网页上的某些项目。    对应的检测注册方法    Page.ClientScript.IsClientScriptIncludeReg

2009-10-27 0comments 97hotness 0likes mikebai Read all
DotNET

Silverlight cross domain policy file helpers

If you are starting to get into integrating web services with Silverlight, you'll notice that you have to have a cross domain policy file in place on the target server, that is to say, the server hosting the service you want to implement.  There are some public web services (Flickr, YouTube, Digg, etc.) that already have these files in place for Flash, but implement in a slightly different way. When calling a cross-domain service, Silverlight will check for the existence of clientaccesspolicy.xml first.  This is the format defined by Silverlight and provides a pretty flexible way to define who can access what services.  If not found, it will then default to look for crossdomain.xml, which is the file format implemented for Adobe Flash.  It is important to note that this file will also still work for most public web services. But now perhaps you are the author of the service that your application is going to consume and/or the public will consume.  There are a few things you want to consider.  First, it would be a best practice to put your service layer on a separate domain other than your site (i.e., api.mysite.com).  In fact, this is how most are doing it these days.  These helps separate more distinctly the services from the web site and also separates the cross-domain security concerns away from the content site versus API access.  Once you have done that you'll want to implement your specific clientaccesspolicy.xml file. When Silverlight 2 was released to beta, I created some quick helper files to assist me with…

2009-10-23 0comments 116hotness 0likes mikebai Read all
DotNET

MSDN的关于跨域访问

http://msdn.microsoft.com/en-us/library/cc645032(VS.95,printer).aspx  

2009-10-23 0comments 103hotness 0likes mikebai Read all
DotNET

SilverLight跨域访问及其常用的几种解决方法

今天在做silverlight访问JSon数据的时候老是出现错误,才发现是跨域的问题,因此将这方面的内容整理一些,列了出来 SilverLight 出于对安全性的考虑默认情况下对URL的访问进行了严格的限制,只允许访问同一子域下的URL资源。下表列出了Silverlight 2.0 中 URL 访问规则:   WebClient对象 Media、images、ASX XAML 文件、Font 文件 流媒体 允许的协议 HTTP, HTTPS HTTP, HTTPS, FILE HTTP, HTTPS, FILE HTTP 跨协议访问 不允许 不允许 不允许 不允许来自HTTPS的访问 跨Web域访问 不允许 如果不是来自HTTPS则允许 不允许 允许 跨安全区域访问(Windows) 不允许 不允许 不允许 不允许 跨安全区域访问(Macintosh) 不允许 允许 不允许 允许 允许重定向 同域允许 允许 同域允许 不允许 如果WCF与SilverLight Web不是在同一站点,那么我们就要在被访问端的根域放上两个XML文件clientaccesspolicy.xml,crossdomain.xml如果要通过WebClinet访问另一站点的资源,那么需要在被访问站点放上域访问策略xml文件,不然在Complete事件里面的事件参数报告空对象引用。 clientaccesspolicy.xml文件格式如何,切忌最好要将编码设置为utf-8,否则极易出错 <?xml version="1.0" encoding="utf-8"?><access-policy>    <cross-domain-access>        <policy>            <allow-from>                <domain uri="*"/>            </allow-from>            <grant-to>                <resource path="/" include-subpaths="true"/>            </grant-to>        </policy>    </cross-domain-access></access-policy> crossdomain.xml文件格式 crossdomain.xml的格式非常简单,其根节点为<cross-domain-policy> ,其下包含一个或多个<allow-access-from>节点,<allow-access-from>有一个属性domain,其值为允许访问的域,可以是确切的 IP 地址、一个确切的域或一个通配符域(任何域)。下边是两个例子: 程序代码<?xml version="1.0"?><cross-domain-policy>  <allow-access-from domain="http://www.lishewen.com.cn/" />  <allow-access-from domain="*.lishewen.com.cn" />  <allow-access-from domain="222.217.221.16" /></cross-domain-policy> 程序代码<?xml version="1.0"?><cross-domain-policy>  <allow-access-from domain="*" /></cross-domain-policy> 第二个例子允许任何域的访问。对于crossdomain.xml文件存放位置,建议将其存放于站点根目录中! 如:http://bbs.lishewen.com.cn/crossdomain.xml 在这我也弄了个Silverlight的例子来测试 http://silverlight.lishewen.net.cn/SyndicationFeedReader/ 关于clientaccesspolicy.xml,crossdomain.xml的具体说明,请大家参看MSDN  http://msdn.microsoft.com/en-us/library/cc645032(VS.95).aspx 文章整理资料来源于:http://www.cnblogs.com/format/articles/1282203.html                http://blog.lishewen.com.cn/post/2008/06/e4bdbfe794a8crossdomainxmle8aea9Silv

2009-10-23 0comments 106hotness 0likes mikebai Read all
DotNET

Silverlight 跨域的策略文件 clientaccesspolicy.xml

Silverlight 跨域的策略文件 clientaccesspolicy.xml  <?xml version="1.0" encoding="utf-8"?><access-policy>    <cross-domain-access>        <policy>            <allow-from>                <domain uri="*"/>            </allow-from>            <grant-to>                <resource path="/" include-subpaths="true"/>            </grant-to>        </policy>    </cross-domain-access></access-policy>   文件编码一定要改成 utf-8  不改的话跨域失败   文件一定要放在网站根目录下 ??????? ???? Love ????? http://www.seewind.cn

2009-10-23 0comments 117hotness 0likes mikebai Read all
DotNET

Silverlight反编译

反编译.NET应用程序已经成为一种很常见的工作方法,而类似Reflector这样的工具使得这项工作更容易了。反编译一个应用程序的原因通常包括了学习编译器是如何转换代码,避开程序库的限制,或直接窃取他人的成果。在浏览器世界里,普遍认为 "查看源文件"是学习如何编码的一个主要手段。 撇开法律上的影响,反编译Silverlight 2应用程序是一件很容易的事情。Silverlight应用程序的所有文件都存储在一个扩展名为XAP的zip压缩文件里。它包含了应用程序所需的所有 XAML、DLL和config文件。一旦解压缩,DLL文件就可以用ILDASM或者你喜欢的反编译器打开。  

2009-10-23 0comments 104hotness 0likes mikebai Read all
dev

html中跨frame显示菜单

多frame现实的时候,一个页面的弹出菜单会被其他frame遮盖住 解决方案:http://www.aspnetexpert.com/demos/Menu/ClientProgramming/CrossFrame/default.aspx http://topic.csdn.net/t/20040922/16/3398864.html

2009-10-20 0comments 110hotness 0likes mikebai Read all
dev

网页下拉菜单

<!DOCTYPE html PUBliC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>css菜单演示</title><style type="text/css"><!--* { margin:0; padding:0; border:0;}body { font-family: arial, 宋体, serif; font-size:12px;}#nav { line-height: 24px; list-style-type: none; background:#666;}#nav a { display: block; width: 80px; text-align:center;}#nav a:link { color:#666; text-decoration:none;}#nav a:visited { color:#666; text-decoration:none;}#nav a:hover { color:#FFF; text-decoration:none; font-weight:bold;}#nav li { float: left; width: 80px; background:#CCC;}#nav li a:hover { background:#999;}#nav li ul { line-height: 27px; list-style-type: none; text-align:left; left: -999em; width: 180px; position: absolute;}#nav li ul li { float: left; width: 180px; background: #F6F6F6;}#nav li ul a { display: block; width: 180px; w\idth: 156px; text-align:left; padding-left:24px;}#nav li ul a:link { color:#666; text-decoration:none;}#nav li ul a:visited { color:#666; text-decoration:none;}#nav li ul a:hover { color:#F3F3F3; text-decoration:none; font-weight:normal; background:#C00;}#nav li:hover ul { left: auto;}#nav li.sfhover ul { left: auto;}#content { clear: left;}--></style><script type=text/javascript>function menuFix() { var sfEls = document.getElementById("nav").getElementsByTagName("li"); for (var i=0; i<sfEls.length; i++)  {  sfEls[i].onmouseover=function()   {   this.className+=(this.className.length>0? " ": "") + "sfhover";  }  sfEls[i].onMouseDown=function()   {   this.className+=(this.className.length>0? " ": "") + "sfhover";  }  sfEls[i].onMouseUp=function()  {   this.className+=(this.className.length>0? " ": "") + "sfhover";  }  sfEls[i].onmouseout=function()   {   this.className=this.className.replace(new RegExp("( ?|^)sfhover\\b"), "");  } }}window.onload=menuFix;</script></head><body><ul id="nav">  <li><a href="#">产品介绍</a>    <ul>      <li><a href="#">产品一</a></li>      <li><a href="#">产品一</a></li>      <li><a href="#">产品一</a></li>      <li><a href="#">产品一</a></li>      <li><a href="#">产品一</a></li>      <li><a href="#">产品一</a></li>    </ul>  </li></ul></body></html>

2009-10-19 0comments 100hotness 0likes mikebai Read all
杂七杂八

解决Windows XP中IIS禁止访问连接的用户过多

使用IIS架设网站服务器的朋友可能经常会遇到这样的情况,老是会提示IIS禁止访问,连接的用户过多,重启IIS后问题即可暂时解决,一但访问的人数再多时又会出现同样的错误提示,下面介绍一种方法从根本上解决Windows XP中IIS禁止访问连接的用户过多,使得我们的Windows XP能够像Windows 2000/2003/2008一样无限制人数的使用IIS。    1、去微软的网站上下载MetaEdit工具。    http://download.microsoft.com/download/iis50/Utility/5.0/NT45/EN-US/MtaEdt22.exe    2、双击下载好的MtaEdt22.exe,按向导提示完成MetaEdit安装,在安装过程中可能会出现相关提示,不用管它,按YES即可。    3、在MetaEdit中设置客户端连接限制的参数。    安装MetaEdit完毕后,在开始菜单的程序组Administrative Tools下点击MetaEdit 2.2运行,在窗口的左边将树展开至LM\W3SVC,直接在W3SVC文件夹上单击,选择右边列表中Name为MaxConnections的项,双击后,在最后Data的文本框中默认的是10,这就是Windows XP专业版IIS默认设置的最大客户端连接数了,现在你可以改变这个默认值了,我把它改为10000,注意:在Win2000 上的IIS客户端连接数最大为2000000000。相关设置的截图如下所示:

2009-10-18 0comments 121hotness 0likes mikebai Read all
1…4748495051…62

Recent Posts

  • c# winform适配高dpi
  • com.microsoft.sqlserver.jdbc.SQLServerException “trustServerCertificate”属性设置为“false”,但驱动程序无法使用安全套接字层 (SSL) 加密与 SQL Server建立安全连接
  • java -cp 用法介绍
  • HTML 容器元素
  • MVC的cshtml的介绍

Recent Comments

No comments to show.

COPYRIGHT © 2025 mikebai.com. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang