现在的位置: 首页 > 综合 > 正文

asp.net 小技巧

2012年08月24日 ⁄ 综合 ⁄ 共 1661字 ⁄ 字号 评论关闭
GridView中数据列的内容太长的时候经常会出现换行
转换成模板列,在内容两边加上 <nowrap> </nowrap>

让   FileUpload   文本框只读

C# code
<asp:FileUpload runat="server" style="height:20px;" unselectable="on" ID="fileUpdate" />

Cookie中的数据以文本的形式存在客户端计算机,考虑它的安全性,最好在将数据存入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:整个网站的性能。









ENTER键可以让光标移到下一个输入框
<input   onkeydown= "if(event.keyCode==13)event.keyCode=9 ">



<%@ Page Language="C#" AutoEventWireup="true" CodeFile="26_虚线效果.aspx.cs" Inherits="_26_虚线效果" %> <!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" > <head runat="server"> <title>无标题页</title> <%-- 方法二--%> <STYLE type=text/css> .dotline { BORDER-BOTTOM-STYLE: dotted; BORDER-LEFT-STYLE: dotted; BORDER-RIGHT-STYLE: dotted; BORDER-TOP-STYLE: dotted } </STYLE> </head> <body> <form id="form1" runat="server"> <div> <hr style="BORDER-BOTTOM-STYLE: dotted; BORDER-LEFT-STYLE: dotted; BORDER-RIGHT-STYLE: dotted; BORDER-TOP-STYLE: dotted" color=#000000 size=1 /> 方法2: <hr class=dotline color=green size=1 /> </div> </form> </body> </html>

<input   type= "file "   onchange= "javascript:document.getElementById( 'image ').src=this.value "/>
<input   type= "image "   src= " "   id= "image "/>
这样在选中要上传的图片时,就可以看见自己要上传的了

抱歉!评论已关闭.