由于CRM系统在部署公司内部使用的时,为了能够使用8G的内存,所以操作系统使用了Windows Server2008R2(Windows Server2008R2是64位系统,同时配置IIS7.0),但是系统在部署后,测试时发现CRM系统中的导入功能不能使用,后经过调试发现从Excel中取数据,它速度快也很方便的代码居然出现了异常,具体代码如下:

string strConn = “Provider=Microsoft.Jet.OLEDB.4.0;” + “Data Source=” +  strFileName + “;” + “Extended Properties=Excel 8.0;”;
OleDbDataAdapter ExcelDA = new OleDbDataAdapter(“SELECT * FROM [" + strSheet + "$]“, strConn);

DataSet dstExcel = new DataSet();
ExcelDA.Fill(dstExcel, “ExcelInfo”);

在上面代码中一直提示“无法找到此类型的驱动”,既然没有驱动,就装了OFFICE的组件,测试后还是一样报此错误,所以就上网搜索得知IIS7会支持一部分32位DLL,但对于与底层绑定较深的组件却不支持。Jet 4.0显示属于后一种组件,微软已经不支持Jet 4.0的升级,所以目前没有,今后也不会再出现Jet 4.0的64位版本,意思说这个组件将无法使用在64位和IIS7.0中。

接着后来再去查找资料说,可以把将应用程序池的Enable 32 bit选项设为True,但IIS的稳定性和兼容性不太好,系统中还用到了Oracle Client,在64位系统一定要使用64位的DLL。所以无法把IIS中应用程序池设置成为32位的应用池的方法来解决这个问题。

只能接续网络搜索终于有了可以在64位置上使用EXCEL的替代方案,使用Microsoft.ACE.OLEDB对Excel进行操作。修改后的脚本如下:

string strConn = “Provider=Microsoft.ACE.OLEDB.12.0;” + “Data Source=”+  strFileName + “;” + “Extended Properties=’Excel 12.0;HDR=YES’”;
OleDbDataAdapter ExcelDA = new OleDbDataAdapter(“SELECT * FROM [" + strSheet + "$]“, strConn);

DataSet dstExcel = new DataSet();
ExcelDA.Fill(dstExcel, “ExcelInfo”);

注意’Excel 12.0;HDR=YES’处的单引号不能少。可是测试后还是不能使用,最后才继续搜索资料得知还需要安装一个“AccessDatabaseEngine_X64”驱动程序,这样就可以解决64位EXCEL的导入问题。果然这段代码终于成功,最终导入的问题也解决了。

经过测试,发现使用Microsoft.ACE.OLEDB对Excel进行操作解决虽然64位为体代码在32位windows server 2003操作系统中居然不能用,为了能够让CRM系统的excel导入程序能够在64位操作系统和32位系统都能用,最后解决方法是在web.config的配置文件里增加一个OSType的参数设置,如果在32的操作系统,就使用以前的导入代码,如果是64位置系统我们就使用后来替代方案。

posted @ 2012-05-08 17:40 痴人说梦 阅读(2) 评论(0) 编辑
//方法一:
// Create a request for the URL.
WebRequest request = WebRequest.Create("http://www.hao123.com");
// If required by the server, set the credentials.
request.Credentials = CredentialCache.DefaultCredentials;
// Get the response.
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
// Display the status.
Response.Write(response.StatusDescription);
// Get the stream containing content returned by the server.
Stream dataStream = response.GetResponseStream();
// Open the stream using a StreamReader for easy access.
StreamReader reader = new StreamReader(dataStream,Encoding.Default);
// Read the content.
string responseFromServer = reader.ReadToEnd();
// Display the content.
Response.Write(responseFromServer);
// Cleanup the streams and the response.
reader.Close();
dataStream.Close();
response.Close();


//方法二:
WebClient client = new WebClient();

// Add a user agent header in case the
// requested URI contains a query.

client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");

Stream data = client.OpenRead("http://www.hao123.com");
StreamReader reader = new StreamReader(data,Encoding.Default);
string s = reader.ReadToEnd();
Response.Write(s);
data.Close();
reader.Close();

//方法三:
WebClient client = new WebClient();
//client.DownloadFile("http://www.hao123.com","123.htm");
string reply = client.DownloadString("http://www.hao123.com");
Response.Write(reply);



//方法四:
using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.IO;
namespace thief
{
class Program
{
static void Main(string[] args)
{

try {
WebClient MyWebClient = new WebClient();
MyWebClient.Credentials = CredentialCache.DefaultCredentials;//获取或设置用于对向Internet资源的请求进行身份验证的网络凭据。
Byte[] pageData = MyWebClient.DownloadData("http://www.163.com");//从指定网站下载数据
string pageHtml = Encoding.Default.GetString(pageData); //如果获取网站页面采用的是GB2312,则使用这句
//string pageHtml = Encoding.UTF8.GetString(pageData); //如果获取网站页面采用的是UTF-8,则使用这句
Console.WriteLine(pageHtml);//在控制台输入获取的内容
using (StreamWriter sw = new StreamWriter("c:\\test\\ouput.html"))//将获取的内容写入文本
{
sw.Write(pageHtml);
}
Console.ReadLine(); //让控制台暂停,否则一闪而过了
}
catch(WebException webEx) {
Console.WriteLine(webEx.Message.ToString());
}
}
}
}
posted @ 2012-02-23 15:18 痴人说梦 阅读(32) 评论(0) 编辑
数据类型和定义

  1. Null是个对象

  JavaScript众多类型中有个Null类型,它有个唯一的值null, 即它的字面量,定义为完全没有任何意义的值。其表现得像个对象,如下检测代码:

alert(typeof null); //弹出 'object'

  如下截图:

  尽管typeof值显示是"object",但null并不认为是一个对象实例。要知道,JavaScript中的值都是对象实例,每个数值都是Number对象,每个对象都是Object对象。因为null是没有值的,所以,很明显,null不是任何东西的实例。因此,下面的值等于false。

alert(null instanceof Object); //为 false

  译者注:null还有被理解为对象占位符一说

  2. NaN是个数值

  NaN本意是表示某个值不是数值,但是其本身却又是数值,且不等于其自身,很奇怪吧,看下面的代码:

alert(typeof NaN); //弹出 'Number'
alert(NaN === NaN); //为 false

  结果如下截图:

  实际上NaN不等于任何东西。要确认某玩意是不是NaN只能使用isNaN.

  3. 无关键字的数组等同于false(关于Truthy和Falsy)

  下面是JavaScript另一个极品怪癖:

alert(new Array() == false); //为 true

  结果如下截图:

  想要知道这里发生了什么,你需要理解truthy和falsy这个概念。它们是一种true/flase字面量。在JavaScript中,所有的非Boolean型值都会内置一个boolean标志,当这个值被要求有boolean行为的时候,这个内置布尔值就会出现,例如当你要跟Boolean型值比对的时候。

  因为苹果不能和梨做比较,所以当JavaScript两个不同类型的值要求做比较的时候,它首先会将其弱化成相同的类型。false, undefined, null, 0, "", NaN都弱化成false。这种强制转化并不是一直存在的,只有当作为表达式使用的时候。看下面这个简单的例子:

var someVar =0;
alert(someVar
== false); //显示 true

  结果如下截图:

  上面测试中,我们试图将数值0和boolean值false做比较,因两者的数据类型不兼容,JavaScript自动强制转换成统一的等同的truthy和falsy,其中0等同于false(正如上面所提及的)。

  你可能注意到了,上面一些等同false的值中并没有空数组。只因空数组是个怪胚子:其本身实际上属于truthy,但是当空数组与Boolean型做比较的时候,其行为表现又属于falsy。不解?这是由原因的。先举个例子验证下空数组的奇怪脾气:

var someVar = []; //空数组
alert(someVar == false); //结果 true
if (someVar) alert('hello'); //alert语句执行, 所以someVar当作true

  结果如下截图,连续弹出两个框框:

  译者注:之所以会有这种差异,根据作者的说法,数组内置toString()方法,例如直接alert的时候,会以join(“,”)的形式弹出字符串,空数组自然就是空字符串,于是等同false。具体可参见作者另外一篇文章,《Twisted logic: understanding truthy & falsy》。不过我个人奇怪的是,像空对象,空函数,弱等于true或者false的时候都显示false,为何?真的因为数组是个怪胎,需要特殊考虑吗?

  为避免强制转换在比较方面的问题,你可以使用强等于(===)代替弱等于(==)。

var someVar = 0;
alert(someVar
== false); //结果 true – 0属于falsy
alert(someVar === false); //结果 false – zero是个数值, 不是布尔值

  结果如下截图(win7 FF4):

  如果你想深入探究JavaScript中类型强制转换等些特有的癖好,可以参见官方相关的文档规范:section 11.9.3 of the ECMA-262

  正则表达式

  4. replace()可以接受回调函数

  这是JavaScript最鲜为人知的秘密之一,v1.3中首次引入。大部分情况下,replace()的使用类似下面:

alert('10 13 21 48 52'.replace(/\d+/g, '*')); //用 * 替换所有的数字

  这是一个简单的替换,一个字符串,一个星号。但是,如果我们希望在替换发生的时候有更多的控制,该怎么办呢?我们只希望替换30以下的数值,该怎么办呢?此时如果仅仅依靠正则表达式是鞭长莫及的。我们需要借助回调函数的东风对每个匹配进行处理。

alert('10 13 21 48 52'.replace(/\d+/g, function(match) {
return parseInt(match) <30?'*' : match;
}));

  当每个匹配完成的时候,JavaScript应用回调函数,传递匹配内容给match参数。然后,根据回调函数里面的过滤规则,要么返回星号,要么返回匹配本身(无替换发生)。

  如下截图:

  5. 正则表达式:不只是match和replace

  不少javascript工程师都是只通过match和replace和正则表达式打交道。但JavaScript所定义的正则表达式相关方法远不止这两个。

  其中值得一提的是test(),其工作方式类似match(),但是返回值却不一样:test()返回的是布尔型,用来验证是否匹配,执行速度高于match()。

alert(/\w{3,}/.test('Hello')); //弹出 'true'

  上面行代码用来验证字符串是否有三个以上普通字符,显然"hello"是符合要求的,所以弹出true。

  结果如下截图:

  我们还应注意RegExp对象,你可以用此创建动态正则表达式对象,例如:

function findWord(word, string) {
var instancesOfWord = string.match(new RegExp('\\b'+word+'\\b', 'ig'));
alert(instancesOfWord);
}
findWord(
'car', 'Carl went to buy a car but had forgotten his credit card.');

  这儿,我们基于参数word动态创建了匹配验证。这段测试代码作用是不区分大小选的情况下选择car这个单词。眼睛一扫而过,测试英文句子中只有一个单词是car,因此这里的演出仅一个单词。\b是用来表示单词边界的。

  结果如下截图:

  函数和作用域

  6. 你可以冒充作用域

  作用域这玩意是用来决定什么变量是可用的,独立的JavaScript(如JavaScript不是运行中函数中)在window对象的全局作用域下操作,window对象在任何情况下都可以访问。然而函数中声明的局部变量只能在该函数中使用。

var animal ='dog';
function getAnimal(adjective) { alert(adjective+''+this.animal); }
getAnimal(
'lovely'); //弹出 'lovely dog'

  这儿我们的变量和函数都声明在全局作用域中。因为this指向当前作用域,在这个例子中就是window。因此,该函数寻找window.animal,也就是'dog'了。到目前为止,一切正常。然而,实际上,我们可以让函数运行在不同的作用域下,而忽视其本身的作用域。我们可以用一个内置的称为call()的方法来实现作用域的冒充。

var animal ='dog';
function getAnimal(adjective) { alert(adjective+''+this.animal); };
var myObj = {animal: 'camel'};
getAnimal.call(myObj,
'lovely'); //弹出 'lovely camel'

  call()方法中的第一个参数可以冒充函数中的this,因此,这里的this.animal实际上就是myObj.animal,也就是'camel'了。后面的参数就作为普通参数传给函数体。

  另外一个与之相关的是apply()方法,其作用于call()一样,不同之处在于,传递给函数的参数是以数组形式表示的,而不是独立的变量们。所以,上面的测试代码如果用apply()表示就是:

getAnimal.apply(myObj, ['lovely']); //函数参数以数组形式发送

  demo页面中,点击第一个按钮的结果如下截图:

  点击第二个和第三个按钮的结果如下:

  7. 函数可以执行其本身

  下面这个是很OK的:

(function() { alert('hello'); })(); //弹出 'hello'

  这里的解析足够简单:声明一个函数,然后因为()解析立即执行它。你可能会奇怪为何要这么做(指直接屁股后面()调用),这看上去是有点自相矛盾的:函数包含的通常是我们想稍后执行的代码,而不是当下解析即执行的,否则,我们就没有必要把代码放在函数中。

  另外一个执行函数自身(self-executing functions (SEFs))的不错使用是为在延迟代码中使用绑定变量值,例如事件的回调(callback),超时执行(timeouts)和间隔执行(intervals)。如下例子:

var someVar ='hello';
setTimeout(
function() { alert(someVar); }, 1000);
var someVar ='goodbye';

  Newbies在论坛里总问这里timeout的弹出为什么是goodbye而不是hello?答案就timeout中的回调函数直到其运行的时候才去赋值someVar变量的值。而那个时候,someVar已经被goodbye重写了好长时间了。

  SEFs提供了一个解决此问题的方法。不是像上面一样含蓄地指定timeout回调,而是直接将someVar值以参数的形式传进去。效果显著,这意味着我们传入并孤立了someVar值,保护其无论后面是地震海啸还是女朋友发飙咆哮都不会改变。

var someVar = 'hello';
setTimeout((
function(someVar) {
returnfunction() { alert(someVar); }
})(someVar),
1000);
var someVar ='goodbye';

  风水轮流转,这次,这里的弹出就是hello了。这就是函数参数和外部变量的点差别了哈。

  例如,最后一个按钮点击后的弹出如下:

  浏览器

  8. FireFox以RGB格式读与返回颜色而非Hex

  直到现在我都没有真正理解为何Mozilla会这样子。为了有个清晰的认识,看下面这个例子:

<!--
#somePara { color: #f90; }
-->
<p id="somePara">Hello, world!</p>
<script>
var ie = navigator.appVersion.indexOf('MSIE') !=-1;
var p = document.getElementById('somePara');
alert(ie
? p.currentStyle.color : getComputedStyle(p, null).color);
</script>

  大部分浏览器弹出的结果是ff9900,而FireFox的结果却是rgb(255, 153, 0),RGB的形式。经常,处理颜色的时候,我们需要花费不少代码将RGB颜色转为Hex。

  下面是上面代码在不同浏览器下的结果:

  其它杂七杂八

  9. 0.1 + 0.2 !== 0.3

  这个古怪的问题不只会出现在JavaScript中,这是计算机科学中一个普遍存在的问题,影响了很多的语言。标题等式输出的结果是0.30000000000000004。

  这是个被称为机器精度的问题。当JavaScript尝试执行(0.1 + 0.2)这行代码的时候,会把值转换成它们喜欢的二进制口味。这就是问题的起源,0.1实际上并不是0.1,而是其二进制形式。从本质上将,当你写下这些值的时候,它们注定要失去精度。你可能只是希望得到个简单的两位小数,但你得到的(根据Chris Pine的注解)是二进制浮点计算。好比你想把一段应该翻译成中文简体,结果出来的却是繁体,其中还是有差异是不一样的。

一般处理与此相关的问题有两个做法:

  1. 转换成整数再计算,计算完毕再转换成希望的小数内容
  2. 调整你的逻辑,设定允许范围为不是指定结果。

  例如,我们不应该下面这样:

var num1=0.1, num2=0.2, shouldEqual=0.3;
alert(num1
+ num2 == shouldEqual); //false

  而可以试试这样:

alert(num1 + num2 > shouldEqual - 0.001&& num1 + num2 < shouldEqual +0.001); //true

  10. 未定义(undefined)可以被定义(defined)

  我们以一个和风细雨的小古怪结束。听起来可能有点奇怪,undefined并不是JavaScript中的保留字,尽管它有特殊的意义,并且是唯一的方法确定变量是否未定义。因此:

var someVar;
alert(someVar
== undefined); //显示 true

  目前为止,一切看上去风平浪静,正常无比,但剧情总是很狗血:

undefined ="I'm not undefined!";
var someVar;
alert(someVar
== undefined); //显示 false!

  这就是为什么jQuery源码中最外部的闭包函数要有个并没有传入的undefined参数,目的就是保护undefined不要被外部的些不良乘虚而入。

posted @ 2011-09-02 18:01 痴人说梦 阅读(5) 评论(0) 编辑
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
  2. <html xmlns="http://www.w3.org/1999/xhtml">  
  3. <head>  
  4. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />  
  5. <title>超级经典一套鼠标控制左右滚动图片带自动翻滚</title>  
  6. </head>  
  7. <body>  
  8. <div class="rollBox">  
  9.      <div class="LeftBotton" onmousedown="ISL_GoUp()" onmouseup="ISL_StopUp()" onmouseout="ISL_StopUp()"></div>  
  10.      <div class="Cont" id="ISL_Cont">  
  11.       <div class="ScrCont">  
  12.        <div id="List1">  
  13.          
  14.         <!-- 图片列表 begin -->  
  15.          <div class="pic">  
  16.           <a href="http://career.sina.com.cn/3/2007/0928/15.html" target="_blank"><img src="http://i0.sinaimg.cn/edu/deco/2007/0928/aiying.jpg" width="109" height="87" alt="周宪环" /></a>  
  17.           <p><a href="http://career.sina.com.cn/3/2007/0928/15.html" target="_blank">周宪环</a></p>  
  18.          </div>         
  19.           
  20.  <div class="pic">  
  21.           <a href="http://career.sina.com.cn/3/2007/0928/16.html" target="_blank"><img src="http://i1.sinaimg.cn/edu/deco/2007/0928/zhenwei.jpg" width="109" height="87" alt="周桢炜" /></a>  
  22.           <p><a href="http://career.sina.com.cn/3/2007/0928/16.html" target="_blank">周桢炜</a></p>  
  23.          </div>  
  24.          <div class="pic">  
  25.           <a href="http://career.sina.com.cn/3/2007/0928/14.html" target="_blank"><img src="http://i2.sinaimg.cn/edu/deco/2007/0928/zhangying.jpg" width="109" height="87" alt="张颖" /></a>  
  26.           <p><a href="http://career.sina.com.cn/3/2007/0928/14.html" target="_blank">张颖</a></p>  
  27.          </div>  
  28.          <div class="pic">  
  29.           <a href="http://career.sina.com.cn/3/2007/0928/17.html" target="_blank"><img src="http://i3.sinaimg.cn/edu/deco/2007/0928/wangnaichao.jpg" width="109" height="87" alt="王乃超" /></a>  
  30.           <p><a href="http://career.sina.com.cn/3/2007/0928/17.html" target="_blank">王乃超</a></p>  
  31.          </div>  
  32.          <div class="pic">  
  33.           <a href="http://career.sina.com.cn/3/2007/0928/19.html" target="_blank"><img src="http://i1.sinaimg.cn/edu/deco/2007/0928/xiewenxiu.jpg" width="109" height="87" alt="谢雯琇" /></a>  
  34.           <p><a href="http://career.sina.com.cn/3/2007/0928/19.html" target="_blank">谢雯琇</a></p>  
  35.          </div>  
  36.  <div class="pic">  
  37.           <a href="http://career.sina.com.cn/3/2007/0928/18.html" target="_blank"><img src="http://i1.sinaimg.cn/edu/deco/2007/0928/lvge.jpg" width="109" height="87" alt="吕铬" /></a>  
  38.           <p><a href="http://career.sina.com.cn/3/2007/0928/18.html" target="_blank">吕铬</a></p>  
  39.          </div>        
  40.          <div class="pic">  
  41.           <a href="http://career.sina.com.cn/3/2007/0927/12.html" target="_blank"><img src="http://i2.sinaimg.cn/edu/deco/2007/0928/zhengru.jpg" width="109" height="87" alt="贾正如" /></a>  
  42.           <p><a href="http://career.sina.com.cn/3/2007/0927/12.html" target="_blank">贾正如</a></p>  
  43.          </div>  
  44.         <!-- 图片列表 end -->  
  45.           
  46.        </div>  
  47.        <div id="List2"></div>  
  48.       </div>  
  49.      </div>  
  50.      <div class="RightBotton" onmousedown="ISL_GoDown()" onmouseup="ISL_StopDown()" onmouseout="ISL_StopDown()"></div>  
  51.     </div>  
  52.    </div>  
  53. <style type="text/css">  
  54. <!--  
  55. .rollBox{width:704px;overflow:hidden;padding:12px 0 5px 6px;}  
  56. .rollBox .LeftBotton{height:52px;width:19px;background:url(http://i3.sinaimg.cn/edu/deco/2007/0924/career/job_mj_069.gif) no-repeat 11px 0;overflow:hidden;float:left;display:inline;margin:25px 0 0 0;cursor:pointer;}  
  57. .rollBox .RightBotton{height:52px;width:20px;background:url(http://i3.sinaimg.cn/edu/deco/2007/0924/career/job_mj_069.gif) no-repeat -8px 0;overflow:hidden;float:left;display:inline;margin:25px 0 0 0;cursor:pointer;}  
  58. .rollBox .Cont{width:663px;overflow:hidden;float:left;}  
  59. .rollBox .ScrCont{width:10000000px;}  
  60. .rollBox .Cont .pic{width:132px;float:left;text-align:center;}  
  61. .rollBox .Cont .pic img{padding:4px;background:#fff;border:1px solid #ccc;display:block;margin:0 auto;}  
  62. .rollBox .Cont .pic p{line-height:26px;color:#505050;}  
  63. .rollBox .Cont a:link,.rollBox .Cont a:visited{color:#626466;text-decoration:none;}  
  64. .rollBox .Cont a:hover{color:#f00;text-decoration:underline;}  
  65. .rollBox #List1,.rollBox #List2{float:left;}  
  66. -->  
  67. </style>  
  68. <script language="javascript" type="text/javascript">  
  69. <!--//--><![CDATA[//><!--  
  70. //图片滚动列表 mengjia 070816  
  71. var Speed = 10; //速度(毫秒)  
  72. var Space = 5; //每次移动(px)  
  73. var PageWidth = 132; //翻页宽度  
  74. var fill = 0; //整体移位  
  75. var MoveLock = false;  
  76. var MoveTimeObj;  
  77. var Comp = 0;  
  78. var AutoPlayObj = null;  
  79. GetObj("List2").innerHTML = GetObj("List1").innerHTML;  
  80. GetObj('ISL_Cont').scrollLeft = fill;  
  81. GetObj("ISL_Cont").onmouseover = function(){clearInterval(AutoPlayObj);}  
  82. GetObj("ISL_Cont").onmouseout = function(){AutoPlay();}  
  83. AutoPlay();  
  84. function GetObj(objName){if(document.getElementById){return eval('document.getElementById("'+objName+'")')}else{return eval('document.all.'+objName)}}  
  85. function AutoPlay(){ //自动滚动  
  86.  clearInterval(AutoPlayObj);  
  87.  AutoPlayObj = setInterval('ISL_GoDown();ISL_StopDown();',5000); //间隔时间  
  88. }  
  89. function ISL_GoUp(){ //上翻开始  
  90.  if(MoveLock) return;  
  91.  clearInterval(AutoPlayObj);  
  92.  MoveLock = true;  
  93.  MoveTimeObj = setInterval('ISL_ScrUp();',Speed);  
  94. }  
  95. function ISL_StopUp(){ //上翻停止  
  96.  clearInterval(MoveTimeObj);  
  97.  if(GetObj('ISL_Cont').scrollLeft % PageWidth - fill != 0){  
  98.   Comp = fill - (GetObj('ISL_Cont').scrollLeft % PageWidth);  
  99.   CompScr();  
  100.  }else{  
  101.   MoveLock = false;  
  102.  }  
  103.  AutoPlay();  
  104. }  
  105. function ISL_ScrUp(){ //上翻动作  
  106.  if(GetObj('ISL_Cont').scrollLeft <= 0){GetObj('ISL_Cont').scrollLeft = GetObj('ISL_Cont').scrollLeft + GetObj('List1').offsetWidth}  
  107.  GetObj('ISL_Cont').scrollLeft -= Space ;  
  108. }  
  109. function ISL_GoDown(){ //下翻  
  110.  clearInterval(MoveTimeObj);  
  111.  if(MoveLock) return;  
  112.  clearInterval(AutoPlayObj);  
  113.  MoveLock = true;  
  114.  ISL_ScrDown();  
  115.  MoveTimeObj = setInterval('ISL_ScrDown()',Speed);  
  116. }  
  117. function ISL_StopDown(){ //下翻停止  
  118.  clearInterval(MoveTimeObj);  
  119.  if(GetObj('ISL_Cont').scrollLeft % PageWidth - fill != 0 ){  
  120.   Comp = PageWidth - GetObj('ISL_Cont').scrollLeft % PageWidth + fill;  
  121.   CompScr();  
  122.  }else{  
  123.   MoveLock = false;  
  124.  }  
  125.  AutoPlay();  
  126. }  
  127. function ISL_ScrDown(){ //下翻动作  
  128.  if(GetObj('ISL_Cont').scrollLeft >= GetObj('List1').scrollWidth){GetObj('ISL_Cont').scrollLeft = GetObj('ISL_Cont').scrollLeft - GetObj('List1').scrollWidth;}  
  129.  GetObj('ISL_Cont').scrollLeft += Space ;  
  130. }  
  131. function CompScr(){  
  132.  var num;  
  133.  if(Comp == 0){MoveLock = false;return;}  
  134.  if(Comp < 0){ //上翻  
  135.   if(Comp < -Space){  
  136.    Comp += Space;  
  137.    num = Space;  
  138.   }else{  
  139.    num = -Comp;  
  140.    Comp = 0;  
  141.   }  
  142.   GetObj('ISL_Cont').scrollLeft -= num;  
  143.   setTimeout('CompScr()',Speed);  
  144.  }else{ //下翻  
  145.   if(Comp > Space){  
  146.    Comp -= Space;  
  147.    num = Space;  
  148.   }else{  
  149.    num = Comp;  
  150.    Comp = 0;  
  151.   }  
  152.   GetObj('ISL_Cont').scrollLeft += num;  
  153.   setTimeout('CompScr()',Speed);  
  154.  }  
  155. }  
  156. //--><!]]>  
  157. </script>  
  158. </body>  
  159. </html> 
posted @ 2011-02-17 14:13 痴人说梦 阅读(417) 评论(0) 编辑
using System.Net.Mail.SmtpClient;
using System.Net.MailMessage; 
protected void btnSendmail_Click(object sender, EventArgs e)
      {
        // System.Web.Mail.SmtpMail.SmtpServer is obsolete in 2.0

        // System.Net.Mail.SmtpClient is the alternate class for this in 2.0

        SmtpClient smtpClient = new SmtpClient();
        MailMessage message = new MailMessage();

        try
        {
            MailAddress fromAddress = new MailAddress(txtEmail.Text, txtName.Text);

            // You can specify the host name or ipaddress of your server

            // Default in IIS will be localhost 

            smtpClient.Host = "localhost";

            //Default port will be 25

            smtpClient.Port = 25;

            //From address will be given as a MailAddress Object

            message.From = fromAddress;

            // To address collection of MailAddress

            message.To.Add("admin1@yoursite.com");
            message.Subject = "Feedback";

            // CC and BCC optional

            // MailAddressCollection class is used to send the email to various users

            // You can specify Address as new MailAddress("admin1@yoursite.com")

            message.CC.Add("admin1@yoursite.com");
            message.CC.Add("admin2@yoursite.com");

            // You can specify Address directly as string

            message.Bcc.Add(new MailAddress("admin3@yoursite.com"));
            message.Bcc.Add(new MailAddress("admin4@yoursite.com"));

            //Body can be Html or text format

            //Specify true if it  is html message

            message.IsBodyHtml = false;

            // Message body content

            message.Body = txtMessage.Text;
         
            // Send SMTP mail

            smtpClient.Send(message);

            lblStatus.Text = "Email successfully sent.";
        }
        catch (Exception ex)
        {
            lblStatus.Text = "Send Email Failed." + ex.Message;
        }
      }
posted @ 2010-12-18 17:46 痴人说梦 阅读(19) 评论(0) 编辑
摘要: /* 将String类型解析为Date类型. parseDate('2006-1-1') return new Date(2006,0,1) parseDate(' 2006-1-1 ') return new Date(2006,0,1) parseDate('2006-1-1 15:14:16') return new Date(2006,0,1,15,14,16) parseDat...阅读全文
posted @ 2010-11-16 18:28 痴人说梦 阅读(54) 评论(0) 编辑
摘要: 因为这两篇太安逸了,东西很多,很实用,所以转到我格子里! 总的来说,如果你要找js 的东西,而不看这两篇的话,肯定要多花好多时间!!哈哈!! 如果你找的javascript的东西的话,建议你 ctrl+F 直接在这个页上找,因为这里80%有你要找的,但是要让你挨着看的话,你就准备看完就去配眼镜!! 事件源对象 event.srcElement.tagName event.srcElement....阅读全文
posted @ 2010-11-16 13:55 痴人说梦 阅读(35) 评论(0) 编辑
摘要: Eric Nelson是微软技术的传道者,也是MSDN UKFlash的技术编辑,他编写了一个列表,列出23个UK开发人员推荐的.NET开源项目。微软的一些开源项目如ASP.NET MVC、DLR、IronRuby、IronPython、MEF等则未列入其中。Eric尝试只包含一个测试框架和一个mock框架,即使有很多其它的项目同样入围。他列出了以下项目:[TEST] xUnit.net- 用于T...阅读全文
posted @ 2010-08-26 17:03 痴人说梦 阅读(211) 评论(0) 编辑
摘要: 本文原理是使用正则表达式匹配location.search中的字符串。其中三个主要函数为 getQueryString()、getQueryStringByName(name)和getQueryStringByIndex(index) 三个主要方法: 方法 说明 getQueryString 获取QueryString的数组。 例如路径QueryStringDemo.html?id=5&type=1&flag=0 调用后返回["id=5", "type=1", "flag=0"] getQueryStringByName 根据QueryString参数名称获取值 getQueryStringByIndex 根据QueryString参数索引获取值 阅读全文
posted @ 2010-08-24 15:40 痴人说梦 阅读(117) 评论(0) 编辑
摘要: function resizeimg(ImgD,iwidth,iheight) { var image=new Image(); image.src=ImgD.src; if(image.width>0 && image.height>0){ if(image.width/image.height>= iwidth/iheight){ if(image.width...阅读全文
posted @ 2010-08-19 17:59 痴人说梦 阅读(137) 评论(2) 编辑