随笔分类 - .net
摘要:protected void Button1_Click(object sender, EventArgs e) { /* 微软为Response对象提供了一个新的方法TransmitFile来解决使用Response.BinaryWrite 下载超过400mb的文件时导致Aspnet_wp.exe进程回收而无法成功下载的问题。 代码如下: */ Response.ContentType = "application/x-zip-compressed"; Response.AddHeader("Content-Disposition", "at
阅读全文
摘要://XmlNode生成XMLXmlDocument xmlnDoc = new XmlDocument();XmlNode xmlnRoot = xmlnDoc.CreateNode(XmlNodeType.Element, "nRoot", String.Empty);XmlNode itemNode = null;for (int i = 0; i Code0 Name0 Code1 Name1 Code2 Name2 //XmlElement生成XMLXmlDocument xmleDoc = new XmlDocument();XmlElement xmleRoot
阅读全文
摘要:CreateCaseInsensitiveHashtable()创建 Hashtable 类具有默认初始容量的不区分大小写的新实例。CreateCaseInsensitiveHashtable(IDictionary)将项从指定字典复制到 Hashtable 类的不区分大小写的新实例,该实例具有与复制项的数量相同的初始容量。CreateCaseInsensitiveHashtable(Int32)创建 Hashtable 类具有指定初始容量的不区分大小写的新实例。CreateCaseInsensitiveSortedList创建 SortedList 类的新实例,该实例忽略字符串的大小写。Eq
阅读全文
摘要:Request.UrlReferrer可以获取客户端上次请求的url的有关信息。 这样我们就可以通过这个属性返回到“上一页”,示例如下1. 首先在Page_load中获得并储存该信息Page_load(object obj,EventArgs e) { if(!IsPostBack){ if(Request.UrlReferrer!=null)// {ViewState["UrlReferrer"]=Request.UrlReferrer.ToString();}} }l 页面回发后会改变Request.UrlReferrer,将其指向当前页面,所以需要进行判断:只有在第一
阅读全文
摘要:比如建立一个名为aspcn,值为灌水小鱼的cookieHttpCookie cookie = new HttpCookie["aspcn"];cookie.Value = "灌水小鱼";Response.AppendCookie(cookie);取出Cookie值也很简单HttpCookie cookie = Request.Cookies["aspcn"];cookieValue = cookie.Value;在一个Cookie中储存多个信息,那也没有问题。比如在名为aspcn的cookie下加多个信息HttpCookie cook
阅读全文
摘要:把localhost换成IP或域名1407为端口号给你一个例子:测试的url地址是, 结果如下: Request.ApplicationPath: /testweb Request.CurrentExecutionFilePath: /testweb/default.aspx Request.FilePath: /testweb/default.aspx Request.Path: /testweb/default.aspx Request.PathInfo: Request.PhysicalApplicationPath: E:\WWW\testweb\ Request.PhysicalPa
阅读全文
摘要:在编译__doPostBack()函数时出现了一个问题,问题描述如下:回发或回调参数无效。在配置中使用 可能出现的问题: 回发或回调参数无效。在配置中使用 或在页面中使用 启用了事件验证。出于安全目的,此功能验证回发或回调事件的参数是否来源于最初呈现这些事件的服务器控件。如果数据有效并且是预期的,则使用ClientScriptManager.RegisterForEventValidation 方法来注册回发或回调数据以进行验证。解决的方法主要有如下几种,要针对自己的情况作出选择:1、在页面的 中添加 EnableEventValidation="false" 就可以了。(
阅读全文
摘要:Asp.net控件开发学习笔记-控件开发基础(一)http://www.cnblogs.com/CareySon/archive/2009/09/30/1576984.htmlAsp.net控件开发学习笔记-控件开发基础(二)http://www.cnblogs.com/CareySon/archive/2009/09/30/1577068.htmlAsp.net控件开发学习笔记-控件开发基础(三)http://www.cnblogs.com/CareySon/archive/2009/10/02/1577402.html Asp.net控件开发学习笔记(四)---Asp.net...
阅读全文
摘要:Obsolete 属性将某个程序实体标记为一个建议不再使用的实体。每次使用被标记为已过时的实体时,随后将生成警告或错误,这取决于属性是如何配置的。例如:复制代码 [System.Obsolete("use class B")]class A{ public void Method() { }}class B{ [System.Obsolete("use NewMethod", true)] public void OldMethod() { } public void NewMethod() { }}在此例中,Obsolete 属性应用于类 A 和方法
阅读全文
摘要:C#高级应用-反射动态调用类的成员范例代码如下://---------------------测试类------------------ using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace InvokeMemberDemo{ /// /// 有关用户信息的相关类 ///class UserInfo { //私有字段及公有属性privateint carID =0; publicint CarID ...
阅读全文
摘要://Type p = Type.GetType("TypeTry.TestClass"); //Type pp = Type.GetType("WebApplication2.Person"); Assembly assembly = Assembly.Load("TypeTry"); //foreach (Type aa in assembly.GetTypes()) //{ // Response.Write(aa.Name); //} Type p = assembly.GetType("TypeTry.TestCla
阅读全文
浙公网安备 33010602011771号