Shaofh

Shaofh

2012年9月30日

Newtonsoft中的几个妙用

摘要: 记录Newtonsoft在序列成Json时的两个妙用JsonSerializerSettings js = new JsonSerializerSettings();//1、属性为Null时不做序列化输出 js.NullValueHandling = NullValueHandling.Ignore;//2、属性为DateTime时,做指定的格式输出 js.Converters.Add(new IsoDateTimeConverter() { DateTimeFormat ="yyyy-MM-dd HH:mm:ss" });JsonConvert.SerializeObje 阅读全文

posted @ 2012-09-30 09:27 sh37 阅读(345) 评论(0) 推荐(0) 编辑

2012年9月5日

Mvc中ViewData与TempData的区别

摘要: ViewData在一个Action中有效,Action所指向的View上下文可任意访问,Controller的其他Aciton指向的View访问无效TempData默认是基于Session存储的TempData在任意View中有效,View上下文可任意访问,但在View中访问完则移除掉。移除后,其他View再访问时变为空了。 阅读全文

posted @ 2012-09-05 17:21 sh37 阅读(131) 评论(0) 推荐(0) 编辑

2011年10月28日

Silverlight中利用ListBox特性实现单选按钮组RadioButtonList和复选按钮组CheckBoxList的功能

摘要: 用过Silverlight都知道,在Silverlight控件中没有类似于Asp。net中的单选按钮组RadioButtonList和复选按钮组CheckBoxList。下面就要利用ListBox来实现单选按钮组RadioButtonList和复选按钮组CheckBoxList。ListBox中有一个SelectionMode的属性来设置单选还是复选,所以我们只需要一个控件就可分别实现RadioButtonList和CheckBoxList两个控件的功能。代码如下:publicclassSysChecks:ListBox{publicSysChecks(){this.DefaultStyleK 阅读全文

posted @ 2011-10-28 14:02 sh37 阅读(615) 评论(0) 推荐(0) 编辑

2011年10月18日

SilverLight中Page也可使用泛型基类

摘要: 最近在用SilverLight+MVC做项目时碰到问题,以往用Asp.net中WebForm做项目时都会在项目框架中使用继承自Page的泛型基类来实现增、删、查、改等基础方法。但在SilverLight却无法使用,如以下代码无法成功编译public partial class CodeClassManage: SysPageBase<CodeClass>{//.......}//其基类SysPageBase实现了增、删、查、改等基础方法public partial class SysPageBase<T> : Page where T:Entity,new(){//实现 阅读全文

posted @ 2011-10-18 11:58 sh37 阅读(219) 评论(0) 推荐(1) 编辑

2007年9月27日

cookie操作

摘要: 今天有空就把操作cookie的写了,虽然很简单,不过免得到时候忘记了。 下面是写cookieHttpCookie cookie = new HttpCookie("Info");//定义cookie对象以及名为Info的项DateTime dt = DateTime.Now;//定义时间对象TimeSpan ts=new TimeSpan(1,0,0,0);//cookie有效作用时间,具体查ms... 阅读全文

posted @ 2007-09-27 11:02 sh37 阅读(182) 评论(1) 推荐(0) 编辑

2007年9月11日

C# 利用net 命令获取域用户列表

摘要: RunCmd("net view")private string RunCmd(string command) { //實例一個Process類,啟動一個獨立進程 Process p = new Process(); //Process類有一個StartInfo屬性,這個是ProcessStartInfo類,包括了一些屬性和方法,下面我們用到了他的幾個屬性: p.StartInfo.FileNam... 阅读全文

posted @ 2007-09-11 16:39 sh37 阅读(1640) 评论(0) 推荐(1) 编辑

2007年8月30日

利用MessageQueue收发消息

摘要: //Send MessageQueue MQueue = new MessageQueue(".\\private$\\MQDemo"); System.Messaging.Message Msg = new System.Messaging.Message(); Msg.Body = textBox1.Text; Msg.Formatter = new System.Messaging.XmlM... 阅读全文

posted @ 2007-08-30 15:57 sh37 阅读(636) 评论(0) 推荐(0) 编辑

2007年7月27日

C# xmlhttp

摘要: //引入com microsoft.xml.3.0 //using MSXML2; public void GetCon(String Url) { // string vs = ""; // try // { // ArrayList arr = new ArrayList(); // XMLHTTP XmlHttp = new MSXML2.XMLHTTPClass(); ; // XmlHt... 阅读全文

posted @ 2007-07-27 11:56 sh37 阅读(1820) 评论(1) 推荐(0) 编辑

2007年6月12日

使用ASP获得AD帐号 “域\用户名”

摘要: 使用ASP获得AD帐号 “域\用户名”<%set wshNetwork=Server.CreateObject("WScript.Network")%><%=wshNetwork.UserName%><%=wshNetwork.ComputerName%><%=wshNetwork.UserDomain%> 阅读全文

posted @ 2007-06-12 21:29 sh37 阅读(968) 评论(0) 推荐(0) 编辑

使用ASP.NET获得AD帐号

摘要: 使用ASP.NET获得AD帐号 “域\用户名”1.在IIS中将访问方式更改为不允许匿名访问2.在Web.config中将验证方式更改为 <identity impersonate="true"/> <authentication mode="Windows" />3.在源代码中使用 var1 = Security.Principal.WindowsI... 阅读全文

posted @ 2007-06-12 21:27 sh37 阅读(485) 评论(0) 推荐(0) 编辑

导航