
ASP.NET/C#
ccyyss
这个作者很懒,什么都没留下…
展开
-
dropdownlist修改了AutoPostBack='true'也不能触发SelectedIndexChanged事件
今天发现写的论坛的Search页面选择页数时不能正常跳转,然后调试发现根本没有触发SelectedIndexChanged事件,看看AutoPostBack属性也为true,找了好一阵子也还没发现什么解决方法,后来把绑定dropdownlist的方法BindData()放到 if (!IsPostBack)外面,终于可以触发SelectedIndexChanged事件了,可原创 2008-12-05 12:00:00 · 1994 阅读 · 0 评论 -
什么时候使用接口?什么时候使用delegates?
<br />你什么时候使用接口?以及你什么时候使用delegates?微软提供了以下的指导思想。<br /><br />在以下情况下使用Delegates很有用:<br /><br />调用一个单一方法。 <br /><br />一个类要进行方法规范(method specification)的多种执行。 <br /><br />使用一个静态方法来执行规范。 <br /><br />想获得类似事件设计的模式。 <br /><br />调用者没有必要知道或获得方法定义的对象。 <br /><br />执行的提原创 2010-12-16 10:26:00 · 1063 阅读 · 0 评论 -
显示所有缓存名字
<br /> IDictionaryEnumerator CacheEnum = HttpRuntime.Cache.GetEnumerator();<br /> while (CacheEnum.MoveNext())<br /> {<br /> str += "<b> [ " + CacheEnum.Key + "] </b> <br /> ";<br /> }<br /> Response.Write原创 2010-11-02 13:39:00 · 901 阅读 · 0 评论 -
C# 实现Pop3代收
using System.Net.Sockets;using System.Collections;using System.IO;using System.Net;using System;using System.Web.Mail;public class POP3{ string POPServer; string user; string pwd;转载 2012-04-28 16:03:43 · 1282 阅读 · 0 评论 -
C#异步调用的好处和方法
最经公司工作需要调用一个外部的webservice,同时要将传出的数据进行保存,以自己以前的习惯,就打算逐步操作,失败啊,完全没考虑过用户体验效果,在同事指点下,意识到使用异步调用的好处,随便将自己找的一些资料留以保存,以戒后误! 我们要明确,为什么要进行异步回调?众所周知,普通方法运行,是单线程的,如果中途有大型操作(如:读取大文件,大批量操作数据库,网络传输等),都会导致方法转载 2013-09-25 15:36:06 · 885 阅读 · 0 评论 -
C# JsonHelper
在c#项目中有时会用到json格式字符串和对象数据类型的转换,下面是一个转换工具类: 说明:根据Json字符串生成对象时,是根据对应的属性名称赋值,多于或少于都不会报错. 使用“DataContractJsonSerializer ”类时需要: 1、引用程序集 System.Runtime.Serialization 和 System.ServiceModel转载 2014-02-26 12:52:22 · 9766 阅读 · 0 评论 -
有关cookie的httponly属性相关
先记录下相关网上的链接,有时间自己再总结一份自己的理解 http://en.wikipedia.org/wiki/HTTP_cookie http://www.cnblogs.com/downmoon/archive/2008/09/11/1289298.html http://msdn.microsoft.com/zh-cn/library/sys转载 2014-09-11 11:22:46 · 1395 阅读 · 0 评论 -
SSH编程的一些问题及解决方法(Granados&&SharpSSH)
1、首先是OPENSSH的无法登陆显示(Granados和Sharpssh都有这个问题)“failed authentication” 打开sshd_config,按照如下的配置修改: # This is the sshd server system-wide configuration file. See# sshd_config(5) for more inform转载 2014-10-21 17:30:28 · 5839 阅读 · 0 评论 -
Multipart Form Post in C#
I recently had to access a web API through C Sharp that required a file upload. This is pretty easy if you have an HTML page with a form tag and you want a user to directly upload the file.转载 2015-11-16 18:01:43 · 1083 阅读 · 0 评论 -
以post方式获取远程数据
<br /> public static string getPostBackStream(string rUrl, string Emails) { // Create a new WebClient instance. WebClient myWebClient = new WebClient(); // Create a new NameValueCollection instance to hold // som原创 2010-06-24 09:42:00 · 1046 阅读 · 0 评论 -
交错数组与三维数组
protected void Page_Load(object sender, EventArgs e) { /******************************* * 交错数组的使用:(数组的数组) * 参考地址:http://msdn.microsoft.com/zh-cn/library/2s05feca(VS.原创 2010-01-05 09:41:00 · 933 阅读 · 0 评论 -
UNIX时间戳与.net日期类的转换
1 将系统时间转换成UNIX时间戳DateTime dtStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970,1,1));DateTime dtNow = DateTime.Parse(DateTime.Now.ToString());TimeSpan toNow = dtNow.Subtract(dtStart)原创 2010-02-24 10:28:00 · 1167 阅读 · 0 评论 -
[转]ASP.net中頁面過長提交后回到原來按鈕位置
当你用asp.net开发web页面时,你会发现,如果你设置了一个页面,如果里面含有多个Button,而且页面很长。当你点击Button后PostBack时,页面总是显示在最上面,极其不方便。但下面几种方法的代码,写帮你解决这个问题。方法一:input type="submit" name="Button1" value="Button" id="Button1" />input t原创 2008-12-17 13:47:00 · 1754 阅读 · 0 评论 -
WebService优点和缺点小结
最近做的几个项目都用到了webservice,通过自己的实践和网上资料的汇总,现在做个小结: 当前WebService是一个热门话题。但是,WebService究竟是什么?,WebService有什么优点和缺点,什么情况下应该用WebService?什么情况下不应该用WebService?是需要我们正确认识的。 实际上,WebService的主要目标是跨平台的可互操作性。为了达到这一目标,We转载 2009-07-28 16:41:00 · 1246 阅读 · 0 评论 -
撰写高效率的.NET程序
撰写高效率的.NET程序影响.NET执行效率的因素 1. 虚拟堆栈机器 2. 垃圾回收器 3. 即时编译器JIT 4. 最优化机器编译器 5. 正确使用.NET机制和.NET Freamwork掌握虚拟堆栈机器小心使用,不要滥用。不要在方法或函数中声明太多太大的局部变量。不要多于64个局部变量。不要用1个大方法。垃圾回收器除非开发人员知道自己做什么,要尽量避免干扰垃圾回收转载 2009-07-28 18:12:00 · 499 阅读 · 0 评论 -
C#中区别多态、重载、重写的概念和语法结构
重写是指重写基类的方法,在基类中的方法必须有修饰符virtual,而在子类的方法中必须指明override。 格式: 基类中: public virtual void myMethod() { } 子类中: public override void myMethod() { } 重写以后,用基类对象和子类对象访问myMethod()方法,结果都是访问在子类中重新定义的方法,基类的方法相当于被覆盖掉原创 2009-07-27 18:16:00 · 600 阅读 · 0 评论 -
asp.net判断输入文字是否是数字
asp.net判断输入文字是否是数字 方案一:/**//// /// 名称:IsNumberic /// 功能:判断输入的是否是数字 /// 参数:string oText:源文本 /// 返回值: bool true:是 false:否 /// public bool IsNumberic(string oText) { try { int var1=Convert.ToInt32 (转载 2009-07-29 09:47:00 · 788 阅读 · 0 评论 -
.Net中抽象类和接口的区别
.Net中抽象类和接口的区别发表:lzhen 阅读: 84次 关键字:抽象类 接口 字体:[大 中 小] 一、抽象类 (1) 抽象方法只作声明,而不包含实现,可以看成是没有实现体的虚方法 (2) 抽象类不能被实例化 (3) 抽象类可以但不是必须有抽象属性和抽象方法,但是一旦有了抽象方法,就一定要把这个类声明为抽象类 (4) 具体派生类必须覆盖基类的抽象方法转载 2009-08-04 10:17:00 · 611 阅读 · 0 评论 -
string.Format字符串格式化说明
string.Format字符串格式化说明 c#中输出{0:X2}是表示输出什么样格式的数据? 答案:十六进制输出 先举几个简单的应用案例:1、格式化货币(跟系统的环境有关,中文系统默认格式化人民币,英文系统格式化美元)string.Format("{0:C}",0.2) 结果为:¥0.20 (英文操作系统结果:$0.20)默认格式化小数点后转载 2009-10-20 09:43:00 · 7020 阅读 · 1 评论 -
获取当前地址
string Urlstr = "http://" + Request.ServerVariables["HTTP_HOST"] + Request.ServerVariables["URL"]; if (Request.ServerVariables["QUERY_STRING"].Trim().Length > 0) UrlStr = Urlstr原创 2010-02-03 11:21:00 · 622 阅读 · 0 评论 -
[Web API] Client 指定請求及回應格式(xml/json)
[Web API] Client 指定請求及回應格式(xml/json)Web API 支援的格式請參考http://www.asp.net/web-api/overview/formats-and-model-binding本篇則要演練xml/json回應 Get定義 Header:Content-Type定義 QueryString請求 PostPO转载 2016-01-07 10:12:12 · 670 阅读 · 0 评论