<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Nffish&#039;s Blog &#187; .Net</title>
	<atom:link href="http://nffish.com/archives/category/net/feed" rel="self" type="application/rss+xml" />
	<link>http://nffish.com</link>
	<description>好记性不如烂笔头</description>
	<lastBuildDate>Mon, 12 Mar 2012 01:40:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>友好的日期及时间显示</title>
		<link>http://nffish.com/archives/326</link>
		<comments>http://nffish.com/archives/326#comments</comments>
		<pubDate>Wed, 02 Dec 2009 07:02:23 +0000</pubDate>
		<dc:creator>Nffish</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[时期]]></category>
		<category><![CDATA[时间]]></category>

		<guid isPermaLink="false">http://nffish.com/?p=326</guid>
		<description><![CDATA[使用使用友好的日期显示会有较好的用户体验。非常适合新闻类的网站。 文章发布距当前时间1小时内的，显示n分钟前。 1天内的，显示小时数。 2天和3天的，显示昨天和前天。 7天内的显示，n天前。 其他的显示日期 以下是C#代码： public static string FriendlyDate(Object sdate) { &#160;&#160; &#160;DateTime date = Convert.ToDateTime(sdate); &#160;&#160; &#160;DateTime...]]></description>
			<content:encoded><![CDATA[<p>使用使用友好的日期显示会有较好的用户体验。非常适合新闻类的网站。<br />
文章发布距当前时间1小时内的，显示n分钟前。<br />
1天内的，显示小时数。<br />
2天和3天的，显示昨天和前天。<br />
7天内的显示，n天前。<br />
其他的显示日期</p>
<p>以下是C#代码：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">public static string FriendlyDate(Object sdate)</li>
<li>{</li>
<li>&nbsp;&nbsp; &nbsp;DateTime date = Convert.ToDateTime(sdate);</li>
<li>&nbsp;&nbsp; &nbsp;DateTime now = DateTime.Now;</li>
<li>&nbsp;</li>
<li>&nbsp;&nbsp; &nbsp;int day = DateTime.Now.Date.Subtract(date).Days;</li>
<li>&nbsp;</li>
<li>&nbsp;&nbsp; &nbsp;//1天内</li>
<li>&nbsp;&nbsp; &nbsp;if (day &lt; 1)</li>
<li>&nbsp;&nbsp; &nbsp;{</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;int hour = (now.Subtract(date)).Hours;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (hour &gt; 1)</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return hour + &quot;小时前&quot;;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;else</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//1小时内</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int minute = (now.Subtract(date)).Minutes;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (minute &gt; 0)</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return minute + &quot;分钟前&quot;;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return date.ToShortDateString();</li>
<li>&nbsp;&nbsp; &nbsp;}</li>
<li>&nbsp;&nbsp; &nbsp;//昨天</li>
<li>&nbsp;&nbsp; &nbsp;else if (day == 1)</li>
<li>&nbsp;&nbsp; &nbsp;{</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return &quot;昨天&quot;;</li>
<li>&nbsp;&nbsp; &nbsp;}</li>
<li>&nbsp;&nbsp; &nbsp;//前天</li>
<li>&nbsp;&nbsp; &nbsp;else if (day == 2)</li>
<li>&nbsp;&nbsp; &nbsp;{</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return &quot;前天&quot;;</li>
<li>&nbsp;&nbsp; &nbsp;}</li>
<li>&nbsp;&nbsp; &nbsp;//4-7天</li>
<li>&nbsp;&nbsp; &nbsp;else if (day &gt;= 3 &amp;&amp; day &lt;= 7)</li>
<li>&nbsp;&nbsp; &nbsp;{</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return day + &quot;天前&quot;;</li>
<li>&nbsp;&nbsp; &nbsp;}</li>
<li>&nbsp;&nbsp; &nbsp;else</li>
<li>&nbsp;&nbsp; &nbsp;{</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return date.ToShortDateString();</li>
<li>&nbsp;&nbsp; &nbsp;}</li>
<li>}</li></ol></div>
]]></content:encoded>
			<wfw:commentRss>http://nffish.com/archives/326/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>中文字符串转换成十六进制的网址格式</title>
		<link>http://nffish.com/archives/321</link>
		<comments>http://nffish.com/archives/321#comments</comments>
		<pubDate>Wed, 25 Nov 2009 07:20:25 +0000</pubDate>
		<dc:creator>Nffish</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[十六进制]]></category>
		<category><![CDATA[字符串]]></category>
		<category><![CDATA[转换]]></category>

		<guid isPermaLink="false">http://nffish.com/?p=321</guid>
		<description><![CDATA[使用中文unicode作网址，第三方控件出现乱码。在我自己的电脑上测试没问题的，到别的机器就有问题了。 一个非常诡异的问题。 估计是编码不一致引起的。 干脆直接把中文转换成了十六进制。 /// &#60;summary&#62; &#160;&#160; &#160; &#160; &#160;/// 中文字符串转换成十六进制的网址格式 &#160;&#160; &#160; &#160; &#160;/// &#60;/summary&#62; &#160;&#160; &#160; &#160; &#160;///...]]></description>
			<content:encoded><![CDATA[<p>使用中文unicode作网址，第三方控件出现乱码。在我自己的电脑上测试没问题的，到别的机器就有问题了。<br />
一个非常诡异的问题。<br />
估计是编码不一致引起的。<br />
干脆直接把中文转换成了十六进制。</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">/// &lt;summary&gt;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;/// 中文字符串转换成十六进制的网址格式</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;/// &lt;/summary&gt;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;/// &lt;param name=&quot;str&quot;&gt;&lt;/param&gt;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;/// &lt;returns&gt;&lt;/returns&gt;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;public static string String2Hex(string str)</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//把字符串放到数组里</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;char[] c = new char[str.Length];</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for (int i = 0; i &lt; str.Length; i++)</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;c[i] = str[i];</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</li>
<li>&nbsp;</li>
<li>&nbsp;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//注意编码,根据需要GB2312或UTF-8</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Byte[] textByte = System.Text.Encoding.GetEncoding(&quot;UTF-8&quot;).GetBytes(c);</li>
<li>&nbsp;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;StringBuilder text = new StringBuilder();</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for (int j = 0; j &lt; textByte.Length; j++)</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// to char</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;char textChar = Convert.ToChar(int.Parse(textByte[j].ToString()));</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// to Hex</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;text.Append(System.Uri.HexEscape(textChar));</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return text.ToString();</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</li></ol></div>
]]></content:encoded>
			<wfw:commentRss>http://nffish.com/archives/321/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ASP.NET中使用AJAX</title>
		<link>http://nffish.com/archives/279</link>
		<comments>http://nffish.com/archives/279#comments</comments>
		<pubDate>Fri, 16 Oct 2009 06:06:46 +0000</pubDate>
		<dc:creator>Nffish</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[ASP.NET]]></category>

		<guid isPermaLink="false">http://nffish.com/?p=279</guid>
		<description><![CDATA[.NET Framework 3.5和2.0都可以用VS2008,VS2005测试通过 1.引用Ajax.dll文件 2.配置Web.config &#60;configSections&#62;节点添加 &#60;httpHandlers&#62;节点添加 3.在需要使用的aspx页面的Page_Load事件中添加 Ajax.Utility.RegisterTypeForAjax(typeof(AjaxDemo)); AjaxDemo是当前这个文件的类名 4.在需要被客户端调用的后台方法前添加AjaxMethod注释 [Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.ReadWrite)] public string[] GetCustomerMac(string clientIP) 5.aspx页面js //触发事件 function Button1_onclick()...]]></description>
			<content:encoded><![CDATA[<p><!-- BODY { FONT-FAMILY:Tahoma; FONT-SIZE:10pt } P { FONT-FAMILY:Tahoma; FONT-SIZE:10pt } DIV { FONT-FAMILY:Tahoma; FONT-SIZE:10pt } TD { FONT-FAMILY:Tahoma; FONT-SIZE:10pt } -->.NET Framework 3.5和2.0都可以用VS2008,VS2005测试通过</p>
<div>1.引用Ajax.dll文件</div>
<div>2.配置Web.config</div>
<div><span style="font-family: monospace;">&lt;configSections&gt;</span>节点添加</div>
<div><span style="font-family: monospace;">&lt;httpHandlers&gt;节点添加</span></div>
<div><span style="font-family: monospace;">3.在需要使用的aspx页面的Page_Load事件中添加</span></div>
<div>
Ajax.Utility.RegisterTypeForAjax(typeof(AjaxDemo));</div>
<div><span style="font-family: monospace;">AjaxDemo是当前这个文件的类名</span></div>
<div><span style="font-family: monospace;"><br />
</span></div>
<div><span style="font-family: monospace;">4.在需要被客户端调用的后台方法前添加AjaxMethod注释</span></div>
<p>[Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.ReadWrite)]<br />
public string[] GetCustomerMac(string clientIP)</p>
<div><span style="font-family: monospace;"><br />
</span></div>
<div><span style="font-family: monospace;">5.aspx页面js</span></div>
<p>//触发事件<br />
function Button1_onclick() {<br />
var ip=document.getElementById(“ip”).value;<br />
AjaxDemo.GetCustomerMac(ip,CustomerMacCallBack);<br />
}</p>
<p>//回调方法<br />
function CustomerMacCallBack(result)<br />
{<br />
var data=result.value;<br />
document.getElementById(“Mac”).value=data;<br />
}</p>
]]></content:encoded>
			<wfw:commentRss>http://nffish.com/archives/279/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>用C#实现MD5加密</title>
		<link>http://nffish.com/archives/126</link>
		<comments>http://nffish.com/archives/126#comments</comments>
		<pubDate>Sat, 05 Jul 2008 09:36:52 +0000</pubDate>
		<dc:creator>Nffish</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[encrypt]]></category>
		<category><![CDATA[MD5]]></category>

		<guid isPermaLink="false">http://nffish.com/?p=126</guid>
		<description><![CDATA[昨晚睡不着，用手机上Google Reader看到关于Hash的文章，突然想到了MD5加密，最近在学.Net平台，所以想整个C#写的Md5加密方法出来。 Google了一下，再结合一些自己的思想。 环境:Windows xp sp3 + vs2008 下载源代码]]></description>
			<content:encoded><![CDATA[<p>昨晚睡不着，用手机上Google Reader看到关于Hash的文章，突然想到了MD5加密，最近在学.Net平台，所以想整个C#写的Md5加密方法出来。</p>
<p>Google了一下，再结合一些自己的思想。</p>
<p><img src="http://pic.yupoo.com/nffish/184175d2945a/2z6xif7b.jpg" alt="MD5加密" /></p>
<p>环境:Windows xp sp3 + vs2008</p>
<p><a href="http://cid-18e24904645e5692.skydrive.live.com/self.aspx/blog|_download/MD5.7z">下载源代码</a></p>
]]></content:encoded>
			<wfw:commentRss>http://nffish.com/archives/126/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
