摘要: ASP.NET读取Excel文件方法一:采用OleDB读取Excel文件:把Excel文件当做一个数据源来进行数据的读取操作,实例如下:publicDataSetExcelToDS(stringPath){stringstrConn="Provider=Microsoft.Jet.OLEDB.4.0;"+"DataSource="+Path+";"+"ExtendedProperties=Excel8.0;";OleDbConnectionconn=newOleDbConnection(strConn);conn. 阅读全文
posted @ 2012-03-09 09:38 Chaoa 阅读(396) 评论(0) 推荐(0) 编辑
摘要: C#中Cookies的存取 c#中cookies的存取操作c#中cookies的存取cookies的创建:在客户端创建一个username的cookies,其值为oneday,有效期为1天.方法1:Response.Cookies["username"].Value="admin";Response.Cookies["username"].Expires=DateTime.Now.AddDays(1);方法2:System.Web.HttpCookie newcookie=newHttpCookie("username&qu 阅读全文
posted @ 2012-03-09 09:36 Chaoa 阅读(322) 评论(0) 推荐(0) 编辑
摘要: 导出成EXCEL:Excel.Application excel=newExcel.Application(); excel.Application.Workbooks.Add(true); excel.Visible=true;for(inti=0; i<this.dataGridView1.ColumnCount; i++) { excel.Cells[1, i+1]=this.dataGridView1.Columns[i].HeaderText; }for(inti=0; i<this.dataGridView1.RowCount-1; i++) {for(intj=0; 阅读全文
posted @ 2012-03-09 08:33 Chaoa 阅读(505) 评论(0) 推荐(0) 编辑
摘要: 这种方法的优势在于发布之前压缩aspx,无须浪费web server的cpu两种方法实现:1)一行一行的读取aspx文件然后处理2)一次性读取aspx文件然后处理处理逻辑:替换" "为" "(将两个空格替换为一个空格),将所有的换行符替换为空字符(极限压缩)注意事项:1)一行一行处理在极限压缩的情况下需要额外的处理服务端控件换行的情况,比如Line 1:<asp:Label runat="server"Line 2: ID="lb1" ....Line 3:.../>这种情况 一行一行处理会出问题2) 阅读全文
posted @ 2012-03-09 08:31 Chaoa 阅读(833) 评论(0) 推荐(0) 编辑
摘要: usingSystem;usingSystem.Collections;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Web;usingSystem.Web.SessionState;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingSystem.Web.UI.HtmlControls;usingSystem.Xml;privateXmlDocument xmlDoc;//load xml fileprivatevoidLoadX 阅读全文
posted @ 2012-03-09 08:30 Chaoa 阅读(194) 评论(0) 推荐(0) 编辑
摘要: protectedvoidApplication_BeginRequest(objectsender, EventArgs e){stringurl=Request.RawUrl.ToString();if(url.ToLower().IndexOf("page/bloglist/")>-1&&url.IndexOf("?")<0){intlastg=url.LastIndexOf("/");intlastdot=url.LastIndexOf(".aspx");stringnurl=S 阅读全文
posted @ 2012-03-09 08:28 Chaoa 阅读(687) 评论(0) 推荐(0) 编辑
摘要: //写一个类public class SplictPage{public static string bind(string content, string Id){string thisnr = "";string thispage = "";string[] temp = content.Trim().Split(<a href="mailto:'{@cpbcw}');">'{$cpbcw$}');</a>if (System.Web.HttpContext.Current. 阅读全文
posted @ 2012-03-09 08:26 Chaoa 阅读(299) 评论(0) 推荐(0) 编辑
摘要: 在Asp.Net中后台实现中实现定时器功能,每过指定的时间自动执行函数功能代码如下:Global.asax 启动定时器voidApplication_Start(objectsender,EventArgse){//在应用程序启动时运行的代码System.Timers.TimermyTimer=newSystem.Timers.Timer(60000);myTimer.Elapsed+=newSystem.Timers.ElapsedEventHandler(OnTimedEvent);myTimer.Interval=60000;myTimer.Enabled=true;}privatest 阅读全文
posted @ 2012-03-09 08:26 Chaoa 阅读(384) 评论(0) 推荐(0) 编辑
摘要: ServerOS = Environment.OSVersion.ToString();//操作系统:CpuSum = Environment.GetEnvironmentVariable("NUMBER_OF_PROCESSORS");//CPU个数:CpuType = Environment.GetEnvironmentVariable("PROCESSOR_IDENTIFIER");//CPU类型:ServerSoft = Request.ServerVariables["SERVER_SOFTWARE"];//信息服务软件:M 阅读全文
posted @ 2012-03-09 08:24 Chaoa 阅读(393) 评论(0) 推荐(0) 编辑
摘要: usingSystem.IOvoidDownload(){System.IO.FileStream r=newSystem.IO.FileStream(FileName, System.IO.FileMode.Open);//文件下载实例化//设置基本信息Response.Buffer=false;Response.AddHeader("Connection","Keep-Alive");Response.ContentType="application/octet-stream";Response.AddHeader("C 阅读全文
posted @ 2012-03-09 08:22 Chaoa 阅读(2553) 评论(1) 推荐(0) 编辑
摘要: using System.Web; public string GetLeaderInfo(string symbol){//获取高管信息的路径 XElement ele = XElement.Load("path.xml");string path = ele.Element("leader").Value;//首次读取缓存string jsoncache = HttpRuntime.Cache.Get(symbol) as string;if (jsoncache == null || jsoncache.Equals("")){ 阅读全文
posted @ 2012-03-09 08:20 Chaoa 阅读(375) 评论(0) 推荐(0) 编辑
摘要: 首先添加对程序集System.Management的引用usingSystem;usingSystem.Management;namespaceConsoleApplication1{classProgram{staticvoidMain(string[]args){ManagementClassmc=newManagementClass("Win32_NetworkAdapterConfiguration");ManagementObjectCollectionnics=mc.GetInstances();foreach(ManagementObjectnicinnics 阅读全文
posted @ 2012-03-09 08:08 Chaoa 阅读(1028) 评论(0) 推荐(0) 编辑
摘要: 在页面上用了iframe带来方便的同时也带来了麻烦,在IE6里能正常显示的iframe在其他的浏览器里确十分丑陋而不方便。为了解决 IE,Firefox,chrome,safari中iframe显示高度自适应问题上网海找了一遍,试了好几个方案都不妥,最后发现了一个可以正常解决的方案。首先加入以下的JS代码:functionstateChangeIE(_frame){if(_frame.readyState=="complete")//state:loading,interactive,complete{AutoHeight();}}functionstateChangeFi 阅读全文
posted @ 2012-03-09 08:04 Chaoa 阅读(1739) 评论(0) 推荐(0) 编辑