VS.NET中的開發技巧
2008-01-02 16:57
204 查看
ENTER键可以让光标移到下一个输入框<input onkeydown="if(event.keyCode==13)event.keyCode=9">MARKCookie中的数据以文本的形式存在客户端计算机,考虑它的安全性,最好在将数据存入Cookie之前对其进行加密。加密的方法很多,比较简单一点的有:Base64,md5,sha等,而相对比较复杂一点的有:DES,TripleDES,RC2,Rijndael等。下面是的代码实现了将数据存入Cookie之前采用散列的算法进行加密.Private void Login_Click(object sender,System EventArgs e){string Name = NameBox.Text;string Pass = PassBox.Text;Response.Cookies["name"].Value = FormsAuthentication.HashPasswordForStoringInConfigFile(Name, "md5");Response.Cookies["pass"].Value = FormsAuthentication.HashPasswordForStoringInConfigFile(Pass, "md5");}加密的方法很多,使用比较复杂的加密算法,安全性比较高些,但占用服务器资源比较大,会减慢整个网站的访问速度。所以对Cookie加密在考虑三个方面:1:安全性,2:Cookie容量,3:整个网站的性能。FUNCTION fn_Split(@sText varchar(8000), @sDelim varchar(20) = ' ')RETURNS @retArray TABLE (idx smallint Primary Key, value varchar(8000))ASBEGINDECLARE @idx smallint,@value varchar(8000),@bcontinue bit,@iStrike smallint,@iDelimlength tinyintIF @sDelim = 'Space'BEGINSET @sDelim = ' 'ENDSET @idx = 0SET @sText = LTrim(RTrim(@sText))SET @iDelimlength = DATALENGTH(@sDelim)SET @bcontinue = 1IF NOT ((@iDelimlength = 0) or (@sDelim = 'Empty'))BEGINWHILE @bcontinue = 1BEGIN--If you can find the delimiter in the text, retrieve the first element and--insert it with its index into the return table.IF CHARINDEX(@sDelim, @sText)>0BEGINSET @value = SUBSTRING(@sText,1, CHARINDEX(@sDelim,@sText)-1)BEGININSERT @retArray (idx, value)VALUES (@idx, @value)END--Trim the element and its delimiter from the front of the string.--Increment the index and loop.SET @iStrike = DATALENGTH(@value) + @iDelimlengthSET @idx = @idx + 1SET @sText = LTrim(Right(@sText,DATALENGTH(@sText) - @iStrike))ENDELSEBEGIN--If you can抰 find the delimiter in the text, @sText is the last value in--@retArray.SET @value = @sTextBEGININSERT @retArray (idx, value)VALUES (@idx, @value)END--Exit the WHILE loop.SET @bcontinue = 0ENDENDENDELSEBEGINWHILE @bcontinue=1BEGIN--If the delimiter is an empty string, check for remaining text--instead of a delimiter. Insert the first character into the--retArray table. Trim the character from the front of the string.--Increment the index and loop.IF DATALENGTH(@sText)>1BEGINSET @value = SUBSTRING(@sText,1,1)BEGININSERT @retArray (idx, value)VALUES (@idx, @value)ENDSET @idx = @idx+1SET @sText = SUBSTRING(@sText,2,DATALENGTH(@sText)-1)ENDELSEBEGIN--One character remains.--Insert the character, and exit the WHILE loop.INSERT @retArray (idx, value)VALUES (@idx, @sText)SET @bcontinue = 0ENDENDENDRETURNEND下面是调用示例:declare @no char(100)set @no='abc,cdesefd,efddc,mgns,aa'select * from fn_Split(@no,',')智能分割字符函数把逗号去掉能把些字分割为这样嫦娥一号成功发射成功分割为这样:0 嫦1 娥2 一3 号4 成5 功6 发7 射8 成9 功====================================关于WEB页的局部打印问题:----------------------------------------<script language="javascript"><!--function PrintNote(){var PrintWin=window.open('about:blank','Print');PrintWin.document.write('<object id="WebBrowser" width=0 height=0 classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object>' + document.all("PrintContent").innerHTML);PrintWin.document.all.WebBrowser.ExecWB(7,1);PrintWin.close();}--></script>--------------------------------------------内容用<div>装起来,并把DIV设置ID<div id="PrintContent" align="center">your GridView</div>------------------------------------<input onclick="javascript:PrintNote();" type="button" value="打印" id="Button2" onserverclick="Button2_ServerClick" runat="server"/>========================================================让GridView产生纵向横向的滚动条。这样就不会吧页面撑打了。CSS code
<style type="text/css" id="print" media="print"> #leftSide, #footerSide { display:none; } </style> <style type="text/css" > .Freezing { position:relative ; table-layout:fixed; top:expression(this.offsetParent.scrollTop); z-index: 10; } .Freezing th{text-overflow:ellipsis;overflow:hidden;white-space: nowrap;padding:2px;} </style>HTML code
<div id="Div1" style="overflow: scroll; height: 140px;width:638px" > Gridview 在这里 </div>
相关文章推荐
- 技巧百问(1):如何使vs.net中的代码有更好的阅读性?
- ASP.NET学习笔记之VS操作使用技巧
- VB.net应用技巧2: 解决VS2015版本中文乱码
- ASP.NET MVC 開發心得分享 (21):Routing 觀念與技巧
- 使用 VS.NET 開發 Lotus Notes Client Application 前置作業
- 技巧和诀窍;在VS 2005里优化ASP.NET 2.0Web项目的Build性能
- 技巧和诀窍;在VS 2005里优化ASP.NET 2.0Web项目的Build性能
- 技巧和诀窍;在VS 2005里优化ASP.NET 2.0Web项目的Build性能(转)
- VS初始化命令 ASP.NET常用技巧
- 安装 VS.NET 2003时的一个技巧.
- [VB.NET源码]VS.NET技巧手册(PDF)
- VS.Net中的快捷键技巧
- VS.Net中的快捷键技巧
- VS初始化命令 ASP.NET常用技巧
- vs.net编程技巧
- 技巧和诀窍;在VS 2005里优化ASP.NET 2.0Web项目的Build性能
- VS.NET开发环境操作小技巧
- Visual Studio .NET使用技巧手册读书笔记之使用VS.NET 2005
- 技巧和诀窍;在VS 2005里优化ASP.NET 2.0Web项目的Build性能
- 技巧和诀窍;在VS 2005里优化ASP.NET 2.0Web项目的Build性能