<?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>days of linnchord &#187; .net</title>
	<atom:link href="http://linnchord.net/archives/tag/net/feed" rel="self" type="application/rss+xml" />
	<link>http://linnchord.net</link>
	<description>南台静坐 : : :</description>
	<lastBuildDate>Thu, 03 Nov 2011 02:22:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>移除firefox上莫名其妙的.NET扩展</title>
		<link>http://linnchord.net/archives/427.html</link>
		<comments>http://linnchord.net/archives/427.html#comments</comments>
		<pubDate>Tue, 02 Jun 2009 05:07:45 +0000</pubDate>
		<dc:creator>linnchord</dc:creator>
				<category><![CDATA[存照]]></category>
		<category><![CDATA[工具]]></category>
		<category><![CDATA[软件开发]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[firefox]]></category>

		<guid isPermaLink="false">http://linnchord.net/?p=427</guid>
		<description><![CDATA[安装.NET3.5SP1以后，Firefox插件栏中会多出一个插件Microsoft .NET Framework Assistant，且无法删除。 原本我也没有太在意，不过今天在网上发现该插件存在严重安全漏洞，这个插件给FireFox添加了目前为止Internet Explorer各个版本中最危险的安全漏洞之一：允许网站轻松而又不惹人察觉的在你的电脑上安装软件。MS都是在干啥啊…… 删除方法如下：（英文原版） 打开 Registry Editor（Vista/Windows 7中在开始菜单搜索框中输入 regedit, 或在XP中运行(R) regedit）。 打开下面键: 32位系统:HKEY_LOCAL_MACHINE / SOFTWARE / Mozilla / Firefox / Extensions 64位系统:HKEY_LOCAL_MACHINE / SOFTWARE / Wow6432Node / Mozilla / Firefox / Extensions 删除{20a82645-c095-46ed-80e3-08825760534b}键. 打开Firefox（如果已经运行需要关闭重新打开）在地址栏输入 about:config 回车。 在过滤框中输入microsoftdotnet快速定位到 general.useragent.extra.microsoftdotnet，右键点击并重置（Reset），再关闭Firefox。（某些系统中没有此项，可直接关闭Firefox跳到下面步骤）. 从资源管理器定位到%SYSTEMDRIVE%\Windows\Microsoft.NET\Framework\v3.5\Windows Presentation Foundation. 删除目录 DotNetAssistantExtension。 再打开Firefox，在插件栏中确认该插件（Microsoft .NET Framework Assistant）已经删除。]]></description>
			<content:encoded><![CDATA[<p>安装.NET3.5SP1以后，Firefox插件栏中会多出一个插件<strong>Microsoft .NET Framework Assistant</strong>，且无法删除。</p>
<p>原本我也没有太在意，不过今天在网上发现该插件存在严重安全漏洞，这个插件给FireFox添加了目前为止Internet Explorer各个版本中最危险的安全漏洞之一：允许网站轻松而又不惹人察觉的在你的电脑上安装软件。MS都是在干啥啊……</p>
<p>删除方法如下：（<a href="http://annoyances.org/exec/show/article08-600">英文原版</a>）</p>
<ol>
<li>打开 <strong>Registry Editor</strong>（Vista/Windows 7中在开始菜单搜索框中输入 <strong>regedit</strong>,  或在XP中<strong>运行(R)</strong> <strong>regedit</strong>）。</li>
<li>打开下面键:
<ul>
<li>32位系统:<strong>HKEY_LOCAL_MACHINE / SOFTWARE / Mozilla / Firefox / Extensions</strong></li>
<li>64位系统:<strong>HKEY_LOCAL_MACHINE / SOFTWARE / Wow6432Node / Mozilla / Firefox / Extensions</strong></li>
</ul>
</li>
<li>删除<strong>{20a82645-c095-46ed-80e3-08825760534b}</strong>键.</li>
<li>打开Firefox（如果已经运行需要关闭重新打开）在地址栏输入 <strong>about:config</strong> 回车。</li>
<li>在过滤框中输入<strong>microsoftdotnet</strong>快速定位到 <strong>general.useragent.extra.microsoftdotnet</strong>，右键点击并重置（Reset），再关闭Firefox。（某些系统中没有此项，可直接关闭Firefox跳到下面步骤）.</li>
<li>从资源管理器定位到<strong>%SYSTEMDRIVE%\Windows\Microsoft.NET\Framework\v3.5\Windows Presentation Foundation</strong>.</li>
<li>删除目录 <strong>DotNetAssistantExtension</strong>。</li>
<li>再打开Firefox，在插件栏中确认该插件（<strong>Microsoft .NET Framework Assistant</strong>）已经删除。</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://linnchord.net/archives/427.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>因为简单，所以困难。</title>
		<link>http://linnchord.net/archives/57.html</link>
		<comments>http://linnchord.net/archives/57.html#comments</comments>
		<pubDate>Wed, 09 Aug 2006 09:23:27 +0000</pubDate>
		<dc:creator>linnchord</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[随记]]></category>
		<category><![CDATA[ASP.NET]]></category>

		<guid isPermaLink="false">http://linnchord.net/2006/08/%e5%9b%a0%e4%b8%ba%e7%ae%80%e5%8d%95%ef%bc%8c%e6%89%80%e4%bb%a5%e5%9b%b0%e9%9a%be%e3%80%82/</guid>
		<description><![CDATA[在网上回复了一个帖子，讨论为什么asp.net开发的网站应用经常表现出不稳定和性能低下，我是这么认为的。 asp.net的页面模型，其实是业界公认非常优秀的开发模型，这种模型简化了原来页面逻辑的烦琐流程，并且有机的和常规的系统模型和面向对象思想结合起来，提高了整个系统的抽象层次，降低了底层开发上手的难度，有利于从更高的层次上组织构架系统，提高开发效率。 但是也正是由于屏蔽了服务的底层，开发上手快、效率高，所以很多人没有或者不能深入理解其机制，只知道简单拖拉然后调用使用控件，只图方便，也不知道什么 地方该用什么地方不该用。现在很多asp.net新入门的人，不知道根本的页面交互模型，不知道http基本机制，甚至不知道HTML，拿着控件到处放， 反正功能出来就ok，这样的东西是什么结果可想而知。 这是目前国内asp.net做网站非常典型的情况，我了解过好几个公司网站都是.net做出来千疮百孔，没办法维护，最后干脆推倒，全部改了java或者php。 不过据我了解，在国外似乎这种情况较少。我思前想后，觉得归根到底，还是市场原因&#8230;市场决定一切，需求决定一切&#8230;后面就没什么可说了，大家都见多了 呵呵]]></description>
			<content:encoded><![CDATA[<p>在网上回复了一个帖子，讨论为什么asp.net开发的网站应用经常表现出不稳定和性能低下，我是这么认为的。</p>
<div class="quote">
<p>asp.net的页面模型，其实是业界公认非常优秀的开发模型，这种模型简化了原来页面逻辑的烦琐流程，并且有机的和常规的系统模型和面向对象思想结合起来，提高了整个系统的抽象层次，降低了底层开发上手的难度，有利于从更高的层次上组织构架系统，提高开发效率。</p>
<p>但是也正是由于屏蔽了服务的底层，开发上手快、效率高，所以很多人没有或者不能深入理解其机制，只知道简单拖拉然后调用使用控件，只图方便，也不知道什么  地方该用什么地方不该用。现在很多asp.net新入门的人，不知道根本的页面交互模型，不知道http基本机制，甚至不知道HTML，拿着控件到处放，  反正功能出来就ok，这样的东西是什么结果可想而知。</p>
<p>这是目前国内asp.net做网站非常典型的情况，我了解过好几个公司网站都是.net做出来千疮百孔，没办法维护，最后干脆推倒，全部改了java或者php。</p>
<p>不过据我了解，在国外似乎这种情况较少。我思前想后，觉得归根到底，还是市场原因&#8230;市场决定一切，需求决定一切&#8230;后面就没什么可说了，大家都见多了 呵呵 </p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://linnchord.net/archives/57.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>利用.NET的XMl序列化解决系统配置问题</title>
		<link>http://linnchord.net/archives/123.html</link>
		<comments>http://linnchord.net/archives/123.html#comments</comments>
		<pubDate>Sat, 22 May 2004 21:29:00 +0000</pubDate>
		<dc:creator>linnchord</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[ASP.NET]]></category>

		<guid isPermaLink="false">http://linnchord.net/2004/05/%e5%88%a9%e7%94%a8net%e7%9a%84xml%e5%ba%8f%e5%88%97%e5%8c%96%e8%a7%a3%e5%86%b3%e7%b3%bb%e7%bb%9f%e9%85%8d%e7%bd%ae%e9%97%ae%e9%a2%98/</guid>
		<description><![CDATA[在Web系统开发中，我们经常需要读取和设置一些系统配置项，常见的例如数据库连接字符串、上传路径等等。 在最初的ASP系统中，比较常用的方法是将值保存为Application或Session变量；在Asp.net系统中，目前比较常见的简单方法是把相应的配置项写入Web.Config中，例如 &#60;?xml version="1.0" encoding="utf-8" ?&#62; &#60;configuration&#62; &#60;system.web&#62; ... &#60;/system.web&#62; &#60;appSettings&#62; &#60;add key="ConnectionString" value="server=(local);database=dbname;uid=user;pwd=pass"/&#62; &#60;/appSettings&#62; &#60;/configuration&#62; 然后在程序中通过如下方式读取 string connString = ConfigurationSettings.AppSettings["ConnectionString"]; 这种方法在系统规模较小复杂度较低的时候也不失为一种简单明了的轻量级方法，不过如果系统较复杂，配置项会较多，同时我们需要按不同模块对配置进行划分，并且还希望能以面向对象方法来对其进行封装，那么如果仍然采用这种过于简化方式就不太合时宜了。 下面，我讲述一下通过XML类序列化解决系统配置问题的方法。 关于XML类序列化和反序列化(另外一种描述是串行化和并行化)的技术细节，大家可以查看MSDN了解；这里简单讲两句，XML序列化是把一个对象序列化到XML文档的过程，反序列化则是从XML输出中重新创建原始状态的对象。 直观表现就是如下图模式 看了这个图，就很清楚了，通过序列化，可以采用面向对象的方法，非常自然和方便的读取和设置系统配置；.NET Framework承担了对象和XML文件映射工作，我们只需要简单的使用就OK。下面我们讲一下具体内容。 上面图示已经表明，首先需要一个XML配置文件，格式内容如上图，具体配置项可以自行增减。 然后我们需要编写一个类，如上图所示；特殊的一点，为了使类能够实现XML序列化，需要在类的所有属性声明前添加属性信息XmlElement，如下所示。 [XmlElement] public string ConnectionString { get { return connectionString; } set { connectionString = value; } } 由于AppConfig类本身没有实现方法，因此我们需要一个配置类AppConfigSetting.cs。类的结构很简单，只需要两个静态方法，Get()获取AppConfig对象，Save()保存AppConfig对象。 另外，我们需要在 Web.Config中添加该XML配置文件的地址。 &#60;appSettings&#62; &#60;add key="AppConfigPath" value="/FilePath/file.config"/&#62; &#60;/appSettings&#62; public [...]]]></description>
			<content:encoded><![CDATA[<p>在Web系统开发中，我们经常需要读取和设置一些系统配置项，常见的例如数据库连接字符串、上传路径等等。</p>
<p>在最初的ASP系统中，比较常用的方法是将值保存为Application或Session变量；在Asp.net系统中，目前比较常见的简单方法是把相应的配置项写入Web.Config中，例如</p>
<pre>
<span style="color: #008080;">&lt;?xml version="1.0" encoding="utf-8" ?&gt;</span>
<span style="color: #000080; font-weight: bold;">&lt;configuration&gt;</span>
<span style="color: #000080; font-weight: bold;">&lt;system.web&gt;</span>
...
<span style="color: #000080; font-weight: bold;">&lt;/system.web&gt;</span>

<span style="color: #000080; font-weight: bold;">&lt;appSettings&gt;</span>
<span style="color: #000080; font-weight: bold;">&lt;add</span> <span style="color: #ff0000;">key=</span><span style="color: #0000ff;">"ConnectionString"</span> <span style="color: #ff0000;">value=</span><span style="color: #0000ff;">"server=(local);database=dbname;uid=user;pwd=pass"</span><span style="color: #000080; font-weight: bold;">/&gt;</span>
<span style="color: #000080; font-weight: bold;">&lt;/appSettings&gt;</span>
<span style="color: #000080; font-weight: bold;">&lt;/configuration&gt;</span>
</pre>
<p>然后在程序中通过如下方式读取</p>
<pre>string connString = ConfigurationSettings.AppSettings["ConnectionString"];</pre>
<p>这种方法在系统规模较小复杂度较低的时候也不失为一种简单明了的轻量级方法，不过如果系统较复杂，配置项会较多，同时我们需要按不同模块对配置进行划分，并且还希望能以面向对象方法来对其进行封装，那么如果仍然采用这种过于简化方式就不太合时宜了。</p>
<hr size="1" noshade="noshade" />
<p>下面，我讲述一下通过XML类序列化解决系统配置问题的方法。</p>
<p>关于XML类序列化和反序列化(另外一种描述是串行化和并行化)的技术细节，大家可以查看MSDN了解；这里简单讲两句，XML序列化是把一个对象序列化到XML文档的过程，反序列化则是从XML输出中重新创建原始状态的对象。</p>
<p>直观表现就是如下图模式</p>
<p><img src="/upload/x2blog/img/xmlserialize.gif" border="0" alt="" /></p>
<p>看了这个图，就很清楚了，通过序列化，可以采用面向对象的方法，非常自然和方便的读取和设置系统配置；.NET Framework承担了对象和XML文件映射工作，我们只需要简单的使用就OK。下面我们讲一下具体内容。</p>
<p>上面图示已经表明，首先需要一个XML配置文件，格式内容如上图，具体配置项可以自行增减。</p>
<p>然后我们需要编写一个类，如上图所示；特殊的一点，为了使类能够实现XML序列化，需要在类的所有属性声明前添加属性信息XmlElement，如下所示。</p>
<pre>[XmlElement]
public string ConnectionString
{
   get { return connectionString; }
   set { connectionString = value; }
}</pre>
<p>由于AppConfig类本身没有实现方法，因此我们需要一个配置类AppConfigSetting.cs。类的结构很简单，只需要两个静态方法，Get()获取AppConfig对象，Save()保存AppConfig对象。</p>
<p>另外，我们需要在 Web.Config中添加该XML配置文件的地址。</p>
<pre>
<strong>&lt;</strong>appSettings<strong>&gt;</strong>
  <strong>&lt;</strong>add key="AppConfigPath" value="/FilePath/file.config"/<strong>&gt;</strong>
<strong>&lt;</strong>/appSettings<strong>&gt;</strong>

public class AppConfigSetting
{
   //获取配置对象
   public static AppConfig Get()
   {
      //尝试获取缓存中的对象
      AppConfig config = (AppConfig)HttpContext.Current.Cache["AppConfig"];

      //如果缓存中没有该配置对象，则直接获取对象
      if (config == null)
      {
         //新建序列化对象并指定其类型
         XmlSerializer serial = new XmlSerializer(typeof(AppConfig));

         try
         {
            string file = HttpContext.Current.Server.MapPath(GetFile());

            //读取文件流
            FileStream fs = new FileStream(file, FileMode.Open);

            //文件流反序列化为对象
            config = (AppConfig)serial.Deserialize(fs);

            fs.Close();

            //将对象加入到缓存中
            HttpContext.Current.Cache.Insert("AppConfig",
                        config, new CacheDependency(file));
         }
         catch (System.IO.FileNotFoundException)
         {
            config = new AppConfig();
         }
      }

      return config;
   }

   //保存配置对象
   public static void Save(AppConfig config)
   {
      string file = HttpContext.Current.Server.MapPath(GetFile());
      XmlSerializer serial = new XmlSerializer (typeof(AppConfig));

      FileStream fs = new FileStream(file, FileMode.Create);

      //对象序列化为文件
      serial.Serialize(fs, config);
      fs.Close();
   }

   //获取配置文件路径
   private static string GetFile()
   {
      string path = (string)HttpContext.Current.Cache["FilePath"];

      if (path == null)
      {
         path=ConfigurationSettings.AppSettings["AppConfigPath"];
         HttpContext.Current.Cache["FilePath"] = path;
      }
      return path;
   }

}</pre>
<p>类的使用非常简单，基本方式如下</p>
<pre>//代码仅为使用演示
AppConfig config = AppConfigSetting.Get();

string connString = config.ConnectionString;

...

config.ConnectionString = connString;
AppConfigSetting.Save(config);</pre>
<p>看到这样的代码，不禁有令人赏心悦目之感；相对于原来的直接读取AppSetting，可谓解脱矣！ <img src='http://linnchord.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>OK，就此结束了。这篇文章只涉及对象序列化的非常简单的应用，没有涉及太多的技术原理和细节，大家要深入了解请参考MSDN。</p>
<p>希望文章能对大家有所补益和启发。 <img src='http://linnchord.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><a href="/upload/x2blog/code/Demo_WebConfigByXmlSerialize.rar">测试源代码工程文件下载(Visual Studio.net 2003)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://linnchord.net/archives/123.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS设计器代码参考.3</title>
		<link>http://linnchord.net/archives/124.html</link>
		<comments>http://linnchord.net/archives/124.html#comments</comments>
		<pubDate>Mon, 17 May 2004 21:36:00 +0000</pubDate>
		<dc:creator>linnchord</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[netsoft]]></category>

		<guid isPermaLink="false">http://linnchord.net/2004/05/css%e8%ae%be%e8%ae%a1%e5%99%a8%e4%bb%a3%e7%a0%81%e5%8f%82%e8%80%833/</guid>
		<description><![CDATA[界面交互 在XML中一共定义了 select/ input_ColorSelect / input_SizeSelect / input_BorderSelect（后3种为颜色/大小/边框输入模式）共4种输入模式，除select为直接选择外，其他在对应控件初始化的时候作为class属性赋值到控件中，类似class代码如下 /* 颜色输入模式input框的样式类 */ .input_ColorSelect { width:100px; font-family:Tahoma; behavior:url(htc/effColorSelect.htc); } 通过behavior属性，把该输入控件和相应的组件相关联，该组件effColorSelect.htc代码如下 &#60;public:ATTACH EVENT="onfocus" ONEVENT="getShow()"/&#62; &#60;public:METHOD NAME="getChange"/&#62; &#60;script LANGUAGE="JScript"&#62; function getShow() { element.blur(); //记录当前交互控件的ID effElement=element.id; //在页面中加载输入控件 ShowControl ("SelectColor"); } function getChange() { //当值发生变化时，对可视化样式元素赋值 SetAttribute(element.id,element.value); } &#60;/script&#62; 其他 设计器中的值输入模式框只是页面中的几个层，通过上面的htc组件触发显示出来，输入后再把值传入到样式属性控件中，同时也会设置可视化样式元素。 另外还需要注意的是，XML文档是可以自行扩展或缩减的，但是在实际应用中，不能完全依据CSS标准来定义，因为可视化元素的style属性会自动格式化。例如如果你在XML中定义border-bottom-width属性，在将值取出时会自动格式化为border-bottom，这样会造成设计器中控件不能匹配。我在MSDN没有查到相关文档，所以只有经过实际测试来验证。 OK,比较关键的代码已经差不多了……希望能对大家有所帮助。 参考 另外再列出部分技术参考，如果大家对其中的技术细节如HTC和XmlDom等有所疑问，可以再详细研究一下，也欢迎大家来和我交流。 MSDN关于JS操作XmlDom的文档 这是英文文档,网上没有看到比较详细的中文文档,好在不复杂,大家将就一下吧 (最近MSDN不知道什么毛病，经常访问有问题，如果无法访问，请先登录msdn，再输入地址浏览) 蓝色理想的HTC教程 网上也没看见比较全面的讲述，这个简单易学,基本概念清楚了。]]></description>
			<content:encoded><![CDATA[<p><strong>界面交互</strong></p>
<p>在XML中一共定义了 select/ input_ColorSelect / input_SizeSelect / input_BorderSelect（后3种为颜色/大小/边框输入模式）共4种输入模式，除select为直接选择外，其他在对应控件初始化的时候作为class属性赋值到控件中，类似class代码如下</p>
<pre>/* 颜色输入模式input框的样式类 */
.input_ColorSelect
{
	width:100px;
	font-family:Tahoma;
	behavior:url(htc/effColorSelect.htc);
}</pre>
<p>通过behavior属性，把该输入控件和相应的组件相关联，该组件effColorSelect.htc代码如下</p>
<pre>&lt;public:ATTACH EVENT=<span style="color: #0000ff;">"onfocus"</span> ONEVENT=<span style="color: #0000ff;">"getShow()"</span>/&gt;
&lt;public:METHOD NAME=<span style="color: #0000ff;">"getChange"</span>/&gt;

&lt;script LANGUAGE=<span style="color: #0000ff;">"JScript"</span>&gt;
<span style="color: #000080; font-weight: bold;">function</span> getShow()
{
element.blur();

<span style="color: #008800; font-style: italic;">//记录当前交互控件的ID </span>
effElement=element.id;

<span style="color: #008800; font-style: italic;">//在页面中加载输入控件</span>
ShowControl (<span style="color: #0000ff;">"SelectColor"</span>);
}

<span style="color: #000080; font-weight: bold;">function</span> getChange()
{
<span style="color: #008800; font-style: italic;">//当值发生变化时，对可视化样式元素赋值</span>
SetAttribute(element.id,element.value);
}
&lt;/script&gt;</pre>
<p><strong>其他</strong></p>
<p>设计器中的值输入模式框只是页面中的几个层，通过上面的htc组件触发显示出来，输入后再把值传入到样式属性控件中，同时也会设置可视化样式元素。</p>
<p>另外还需要注意的是，XML文档是可以自行扩展或缩减的，但是在实际应用中，不能完全依据CSS标准来定义，因为可视化元素的style属性会自动格式化。例如如果你在XML中定义border-bottom-width属性，在将值取出时会自动格式化为border-bottom，这样会造成设计器中控件不能匹配。我在MSDN没有查到相关文档，所以只有经过实际测试来验证。</p>
<p>OK,比较关键的代码已经差不多了……希望能对大家有所帮助。<br />
<strong>参考</strong></p>
<p>另外再列出部分技术参考，如果大家对其中的技术细节如HTC和XmlDom等有所疑问，可以再详细研究一下，也欢迎大家来和我交流。</p>
<p><a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html/DOM_HDI_JS.asp" target="_blank">MSDN关于JS操作XmlDom的文档</a></p>
<p>这是英文文档,网上没有看到比较详细的中文文档,好在不复杂,大家将就一下吧 <img src='http://linnchord.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>(最近MSDN不知道什么毛病，经常访问有问题，如果无法访问，请先登录msdn，再输入地址浏览)</p>
<p><a href="http://www.blueidea.com/tech/web/2003/1227.asp" target="_blank">蓝色理想的HTC教程 </a></p>
<p>网上也没看见比较全面的讲述，这个简单易学,基本概念清楚了。</p>
]]></content:encoded>
			<wfw:commentRss>http://linnchord.net/archives/124.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS设计器代码参考.2</title>
		<link>http://linnchord.net/archives/125.html</link>
		<comments>http://linnchord.net/archives/125.html#comments</comments>
		<pubDate>Wed, 12 May 2004 11:31:00 +0000</pubDate>
		<dc:creator>linnchord</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[netsoft]]></category>

		<guid isPermaLink="false">http://linnchord.net/2004/05/css%e8%ae%be%e8%ae%a1%e5%99%a8%e4%bb%a3%e7%a0%81%e5%8f%82%e8%80%832/</guid>
		<description><![CDATA[设计器初始化 Js脚本读取解析样式元素的style属性值，然后为设计器中构建的控件赋值 //设计器初始化 function Init() { //获得由服务器端赋值的样式属性值 var txt=document.all("DemoShow").style.cssText; if (txt.length>0) { var strClassName; //解析字符串 var aryClass = txt.split(/[:;]/); for( i in aryClass) { var str = aryClass[i].replace(/(^s*)&#124;(s*$)/g, ""); if(!(i%2==1)) { //当i为奇数时，解析的字符串应该为样式属性名称 strClassName=str; } else { //当i为偶数时，获得属性值 //属性名称即控件ID //判断该属性对应的控件是输入框还是选择列表 if(document.all(strClassName).type=="select-one") { //如果是选择列表通过setIndexOfValue函数设定选择项 setIndexOfValue(strClassName,str); } else { document.all(strClassName).value=str; } } i++; } } }]]></description>
			<content:encoded><![CDATA[<p><strong>设计器初始化</strong></p>
<p>Js脚本读取解析样式元素的style属性值，然后为设计器中构建的控件赋值 </p>
<p></p>
<pre>
//设计器初始化
function Init()
{
   //获得由服务器端赋值的样式属性值
   var txt=document.all("DemoShow").style.cssText;

   if (txt.length>0)
   {
      var strClassName;

      //解析字符串
      var aryClass = txt.split(/[:;]/);

      for( i in aryClass)
      {
         var str = aryClass[i].replace(/(^s*)|(s*$)/g, "");
         if(!(i%2==1))
         {
            //当i为奇数时，解析的字符串应该为样式属性名称
            strClassName=str;
         }
         else
         {
            //当i为偶数时，获得属性值

              //属性名称即控件ID
            //判断该属性对应的控件是输入框还是选择列表
            if(document.all(strClassName).type=="select-one")
            {

               //如果是选择列表通过setIndexOfValue函数设定选择项
               setIndexOfValue(strClassName,str);

            }
            else
            {
               document.all(strClassName).value=str;
            }
         }
         i++;
      }
   }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://linnchord.net/archives/125.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS设计器代码参考.1</title>
		<link>http://linnchord.net/archives/126.html</link>
		<comments>http://linnchord.net/archives/126.html#comments</comments>
		<pubDate>Mon, 10 May 2004 20:11:00 +0000</pubDate>
		<dc:creator>linnchord</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[netsoft]]></category>

		<guid isPermaLink="false">http://linnchord.net/2004/05/css%e8%ae%be%e8%ae%a1%e5%99%a8%e4%bb%a3%e7%a0%81%e5%8f%82%e8%80%831/</guid>
		<description><![CDATA[这里对前面讲的CSS设计器系统关键代码作一些小结，如果没有看过前面文章请先参看前文 解析CSS样式文件 这段代码主要作用是把CSS文件分解为多个样式类，并按名称/文本属性生产ClassItem对象，并保存在一个ArrayList(cssList)中(C#代码) //读取文件 FileInfo theSource= new FileInfo (@m_filePath); StreamReader reader = theSource.OpenText(); //将文件流转化为文本 m_cssText = reader.ReadToEnd(); reader.Close(); //定义CSS文本分割符 char[] delimiters = new char[] { '{','}'}; int iCheck = 1;string className = null; //将文本转化为ArrayList foreach ( string substring in m_cssText.Split(delimiters)) { if (iCheck%2==0) //当iCHeck为偶数时,字符串为样式属性内容 //将解析的样式名和属性作为ClassItem对象存入cssList cssList.Add( new ClassItem ( className, substring.Trim() ) ); else //当iCHeck为奇数时,字符串为样式名,暂存 [...]]]></description>
			<content:encoded><![CDATA[<p>这里对前面讲的CSS设计器系统关键代码作一些小结，如果没有看过前面文章请先参看前文<br />
<strong>解析CSS样式文件</strong></p>
<p>这段代码主要作用是把CSS文件分解为多个样式类，并按名称/文本属性生产ClassItem对象，并保存在一个ArrayList(cssList)中(C#代码)</p>
<pre>
<span style="color: #008800; font-style: italic;">//读取文件</span>
 FileInfo theSource= <span style="color: #000080; font-weight: bold;">new</span> FileInfo (@m_filePath);
 StreamReader reader = theSource.OpenText();

 <span style="color: #008800; font-style: italic;">//将文件流转化为文本</span>
 m_cssText = reader.ReadToEnd();
 reader.Close();

 <span style="color: #008800; font-style: italic;">//定义CSS文本分割符</span>
 <span style="color: #000080; font-weight: bold;">char</span>[] delimiters = <span style="color: #000080; font-weight: bold;">new</span> <span style="color: #000080; font-weight: bold;">char</span>[] <span style="color: #000080; font-weight: bold;">{</span> <span style="color: #800080;">'{'</span>,<span style="color: #800080;">'}'</span><span style="color: #000080; font-weight: bold;">}</span>;
 <span style="color: #000080; font-weight: bold;">int</span> iCheck = <span style="color: #0000ff;">1</span>;<span style="color: #000080; font-weight: bold;">string</span> className = <span style="color: #000080; font-weight: bold;">null</span>;

 <span style="color: #008800; font-style: italic;">//将文本转化为ArrayList</span>
 <span style="color: #000080; font-weight: bold;">foreach</span> ( <span style="color: #000080; font-weight: bold;">string</span> substring <span style="color: #000080; font-weight: bold;">in</span> m_cssText.Split(delimiters))
 <span style="color: #000080; font-weight: bold;">{</span>
     <span style="color: #000080; font-weight: bold;">if</span> (iCheck%<span style="color: #0000ff;">2</span>==<span style="color: #0000ff;">0</span>)
         <span style="color: #008800; font-style: italic;">//当iCHeck为偶数时,字符串为样式属性内容 </span>
         <span style="color: #008800; font-style: italic;">//将解析的样式名和属性作为ClassItem对象存入cssList        </span>
         cssList.Add( <span style="color: #000080; font-weight: bold;">new</span> ClassItem ( className, substring.Trim() ) );

     <span style="color: #000080; font-weight: bold;">else</span>
         <span style="color: #008800; font-style: italic;">//当iCHeck为奇数时,字符串为样式名,暂存 </span>
         className = substring.Trim(); iCheck++;
 <span style="color: #000080; font-weight: bold;">}</span>
 </pre>
<p><strong>交互界面构建</strong></p>
<p>交互界面由Javascript通过XmlDocument读取Xml文件动态生成。</p>
<p>首先要读取XML文件，然后遍历整个XML文件，先遍历样式分类，再对每个分类遍历其下的所有样式属性。比较关键的代码是对XML的遍历，下面是对样式分类的遍历代码。</p>
<pre>
<span style="color: #008800; font-style: italic;">//LoadXML是XML文件读取函数</span>
<span style="color: #000080; font-weight: bold;">var</span> dom = LoadXML(<span style="color: #0000ff;">"css.xml"</span>);

<span style="color: #008800; font-style: italic;">//通过XPath和selectNodes方法返回一个XMLDOMNodeList对象</span>
<span style="color: #000080; font-weight: bold;">var</span> oNode = dom.selectNodes(<span style="color: #0000ff;">"//Category/Name"</span>);

<span style="color: #008800; font-style: italic;">//获取该对象长度，即XML文档中该路径节点的数量</span>
<span style="color: #000080; font-weight: bold;">var</span> intCategory = oNodes.length;
<span style="color: #000080; font-weight: bold;">for</span> (i=<span style="color: #0000ff;">0</span>; i&amp;lt;intCategory; i++)
{
<span style="color: #008800; font-style: italic;">//获取集合中的节点</span>
oNode = oNodes.nextNode;

<span style="color: #000080; font-weight: bold;">if</span> (oNode != <span style="color: #000080; font-weight: bold;">null</span>)
{
<span style="color: #008800; font-style: italic;">//样式分类界面构建代码-略 ……</span>
}
}
</pre>
<p>样式输入控件构建函数，该函数作用是根据XPath路径查询XML定义，生成交互控件</p>
<pre>
<span style="color: #000080; font-weight: bold;">function</span> BuildInput ( path )
{
<span style="color: #000080; font-weight: bold;">var</span> str=<span style="color: #0000ff;">""</span>;
<span style="color: #000080; font-weight: bold;">var</span> aNode=<span style="color: #000080; font-weight: bold;">null</span>;
<span style="color: #000080; font-weight: bold;">var</span> attValue=<span style="color: #000080; font-weight: bold;">null</span>;

<span style="color: #008800; font-style: italic;">//通过selectSingleNode返回符合条件的第一个节点 </span>
<span style="color: #000080; font-weight: bold;">var</span> actNode = dom.selectSingleNode(path+<span style="color: #0000ff;">"ActionType"</span>);
<span style="color: #000080; font-weight: bold;">var</span> nameNode = dom.selectSingleNode(path+<span style="color: #0000ff;">"CssName"</span>);

<span style="color: #008800; font-style: italic;">//如果属性为选择输入，则读取SelectItems，并构建select控件 </span>
<span style="color: #000080; font-weight: bold;">if</span> (actNode.text==<span style="color: #0000ff;">"select"</span>)
{
str += <span style="color: #0000ff;">"&lt;select id='"</span>+nameNode.text+<span style="color: #0000ff;">"' name='"</span>+nameNode.text+<span style="color: #0000ff;">"'class='eSelect'&gt;"</span>;

<span style="color: #008800; font-style: italic;">//查询该项的所有选择列表项 </span>
<span style="color: #000080; font-weight: bold;">var</span> itemsNodes = dom.selectNodes (path+<span style="color: #0000ff;">"SelectItems/Item"</span>);
str += <span style="color: #0000ff;">"&lt;option value='-1'&gt;未设置&lt;/option&gt;"</span>;
<span style="color: #000080; font-weight: bold;">for</span> (ii=<span style="color: #0000ff;">0</span>;ii&lt;itemsNodes.length;ii++){
aNode = dom.selectSingleNode (path+<span style="color: #0000ff;">"SelectItems/Item["</span>+ii+<span style="color: #0000ff;">"]"</span>);

<span style="color: #008800; font-style: italic;">//如果该项含有Name属性则在列表中显示Name属性值</span>
attValue = aNode.getAttribute(<span style="color: #0000ff;">"Name"</span>)
<span style="color: #000080; font-weight: bold;">var</span> txtNode = dom.selectSingleNode (path+<span style="color: #0000ff;">"SelectItems/Item["</span>+ii+<span style="color: #0000ff;">"]"</span>);
<span style="color: #000080; font-weight: bold;">if</span> (attValue==<span style="color: #000080; font-weight: bold;">null</span>)
str += <span style="color: #0000ff;">"&lt;option value='"</span>+txtNode.text+<span style="color: #0000ff;">"'&gt;"</span>+txtNode.text+<span style="color: #0000ff;">"&lt;/option&gt;"</span>;
<span style="color: #000080; font-weight: bold;">else</span>
str += <span style="color: #0000ff;">"&lt;option value='"</span>+txtNode.text+<span style="color: #0000ff;">"'&gt;"</span>+attValue+<span style="color: #0000ff;">"&lt;/option&gt;"</span>;
}
str += <span style="color: #0000ff;">"&lt;/select&gt;"</span>;
}
<span style="color: #000080; font-weight: bold;">else</span>
<span style="color: #008800; font-style: italic;">//如果属性为其他模式，则构建input输入，设置class属性为ActionType</span>
{
str = <span style="color: #0000ff;">"&lt;input name='"</span>+nameNode.text+<span style="color: #0000ff;">"' id='"</span>+nameNode.text+<span style="color: #0000ff;">"' class='"</span>+actNode.text+<span style="color: #0000ff;">"'&gt;"</span>;
}

<span style="color: #000080; font-weight: bold;">return</span>(str);
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://linnchord.net/archives/126.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>asp.net开发技巧</title>
		<link>http://linnchord.net/archives/127.html</link>
		<comments>http://linnchord.net/archives/127.html#comments</comments>
		<pubDate>Thu, 06 May 2004 22:48:00 +0000</pubDate>
		<dc:creator>linnchord</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[ASP.NET]]></category>

		<guid isPermaLink="false">http://linnchord.net/2004/05/aspnet%e5%bc%80%e5%8f%91%e6%8a%80%e5%b7%a7/</guid>
		<description><![CDATA[不断学习的过程中，经常遇到一些代码编写技巧性的东西，虽然通常不是什么特别困难的技术问题，不过也十分重要。 为避免遗忘并方便查证，特记录于此。 在页面中直接发文件到客户端 说明: 将下面代码加入干净的aspx页或隐藏代码页即可(此处假设页面为download.aspx)； 效果: 链接到地址[download.aspx?file=filename]直接产生下载； 目的: 与直接链接文件地址下载方式比较，可以在下载前加入代码，统计下载数；另外，根据需要可以改写参数(例如改为数据库中该下载文件记录的id)，做简单的代码处理，就可以在一定程度上隐藏下载地址，防止盗链&#8230;&#8230; private void Page_Load(object sender, System.EventArgs e) { string path = Server.MapPath(Request.Params["File"]); System.IO.FileInfo file = new System.IO.FileInfo(path); Response.Clear(); Response.AddHeader(“Content-Disposition”, “attachment; filename=” + file.Name); Response.AddHeader(“Content-Length”, file.Length.ToString()); Response.ContentType = “application/octet-stream”; Response.WriteFile(file.FullName); Response.End(); }]]></description>
			<content:encoded><![CDATA[<p><font face="Verdana">不断学习的过程中，经常遇到一些代码编写技巧性的东西，虽然通常不是什么特别困难的技术问题，不过也十分重要。 </p>
<p>为避免遗忘并方便查证，特记录于此。 </p>
<p><strong style="COLOR: rgb(128,0,0)">在页面中直接发文件到客户端</strong> </p>
<p></font><font style="FONT-FAMILY: Courier New">说明: 将下面代码加入干净的aspx页或隐藏代码页即可(此处假设页面为download.aspx)； <br />效果: 链接到地址[download.aspx?file=filename]直接产生下载； <br />目的: 与直接链接文件地址下载方式比较，可以在下载前加入代码，统计下载数；另外，根据需要可以改写参数(例如改为数据库中该下载文件记录的id)，做简单的代码处理，就可以在一定程度上隐藏下载地址，防止盗链&hellip;&hellip; </p>
<p><font color="#000000"><font color="#800000"><strong>private</strong></font> <font color="#ff8000"><strong>void</strong></font> Page_Load<font color="#0000ff">(</font>object sender<font color="#0000ff">,</font> System<font color="#0000ff">.</font>EventArgs e<font color="#0000ff">)</font> <br /><font color="#0000ff">{</font> <br />string path <font color="#0000ff">=</font> Server<font color="#0000ff">.</font>MapPath<font color="#0000ff">(</font>Request<font color="#0000ff">.</font>Params<font color="#0000ff">[</font><font color="#ff00ff">"File"</font><font color="#0000ff">]</font><font color="#0000ff">)</font><font color="#0000ff">;</font> <br />System<font color="#0000ff">.</font>IO<font color="#0000ff">.</font>FileInfo file <font color="#0000ff">=</font> <font color="#800000"><strong>new</strong></font> System<font color="#0000ff">.</font>IO<font color="#0000ff">.</font>FileInfo<font color="#0000ff">(</font>path<font color="#0000ff">)</font><font color="#0000ff">;</font> </p>
<p>Response<font color="#0000ff">.</font>Clear<font color="#0000ff">(</font><font color="#0000ff">)</font><font color="#0000ff">;</font> <br />Response<font color="#0000ff">.</font>AddHeader<font color="#0000ff">(</font><font color="#ff00ff">“Content-Disposition”</font><font color="#0000ff">,</font> <font color="#ff00ff">“attachment; filename=”</font> <font color="#0000ff">+</font> file<font color="#0000ff">.</font>Name<font color="#0000ff">)</font><font color="#0000ff">;</font> </p>
<p>Response<font color="#0000ff">.</font>AddHeader<font color="#0000ff">(</font><font color="#ff00ff">“Content-Length”</font><font color="#0000ff">,</font> file<font color="#0000ff">.</font>Length<font color="#0000ff">.</font>ToString<font color="#0000ff">(</font><font color="#0000ff">)</font><font color="#0000ff">)</font><font color="#0000ff">;</font> <br />Response<font color="#0000ff">.</font>ContentType <font color="#0000ff">=</font> <font color="#ff00ff">“application/octet-stream”</font><font color="#0000ff">;</font> <br />Response<font color="#0000ff">.</font>WriteFile<font color="#0000ff">(</font>file<font color="#0000ff">.</font>FullName<font color="#0000ff">)</font><font color="#0000ff">;</font> <br />Response<font color="#0000ff">.</font>End<font color="#0000ff">(</font><font color="#0000ff">)</font><font color="#0000ff">;</font> <br /><font color="#0000ff">}</font> </font></font></p>
]]></content:encoded>
			<wfw:commentRss>http://linnchord.net/archives/127.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS设计器之界面交互</title>
		<link>http://linnchord.net/archives/129.html</link>
		<comments>http://linnchord.net/archives/129.html#comments</comments>
		<pubDate>Thu, 29 Apr 2004 16:55:00 +0000</pubDate>
		<dc:creator>linnchord</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[设计]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[netsoft]]></category>
		<category><![CDATA[界面设计]]></category>

		<guid isPermaLink="false">http://linnchord.net/2004/04/css%e8%ae%be%e8%ae%a1%e5%99%a8%e4%b9%8b%e7%95%8c%e9%9d%a2%e4%ba%a4%e4%ba%92/</guid>
		<description><![CDATA[整个操作交互过程，除了最后保存文件外，其他都是由javascript完成。 首先DesignerBuild函数读取XML样式属性定义文件，构建整个设计器界面。然后Init函数读取服务器端赋给设计元素的Style属性，并把属性作为输入控件ID在设计器中查找并赋值，完成初始化。 在操作过程中，根据输入控件的样式类Class，触发绑定的HTC组件，做相应的客户端操作。 最后再读取设计元素的style属性，保存。 设计器界面 不同的设计元素 不同输入控件的不同class属性（根据XML中ActionType生成）触发不同HTC组件，实现不同输入模式。 由于商业原因，这里不便提供源代码；我将在后面提供部分关键代码供参考。]]></description>
			<content:encoded><![CDATA[<p>整个操作交互过程，除了最后保存文件外，其他都是由javascript完成。 </p>
<p>首先DesignerBuild函数读取XML样式属性定义文件，构建整个设计器界面。然后Init函数读取服务器端赋给设计元素的Style属性，并把属性作为输入控件ID在设计器中查找并赋值，完成初始化。 </p>
<p>在操作过程中，根据输入控件的样式类Class，触发绑定的HTC组件，做相应的客户端操作。 </p>
<p>最后再读取设计元素的style属性，保存。 </p>
<p>设计器界面 </p>
<p><img src="http://linnchord.net/upload/x2blog/img/cssdesigner.gif" alt="" /> </p>
<p>不同的设计元素 </p>
<p><img src="http://linnchord.net/upload/x2blog/img/cssdesigner1.gif" alt="" /> </p>
<p>不同输入控件的不同class属性（根据XML中ActionType生成）触发不同HTC组件，实现不同输入模式。 </p>
<p><img src="http://linnchord.net/upload/x2blog/img/cssdesignerinput1.gif" alt="" /> </p>
<p><img src="http://linnchord.net/upload/x2blog/img/cssdesignerinput2.gif" alt="" /> </p>
<p><img src="http://linnchord.net/upload/x2blog/img/cssdesignerinput3.gif" alt="" /> </p>
<p>由于商业原因，这里不便提供源代码；我将在后面提供部分关键代码供参考。</p>
]]></content:encoded>
			<wfw:commentRss>http://linnchord.net/archives/129.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS设计器之流程</title>
		<link>http://linnchord.net/archives/132.html</link>
		<comments>http://linnchord.net/archives/132.html#comments</comments>
		<pubDate>Fri, 23 Apr 2004 17:11:00 +0000</pubDate>
		<dc:creator>linnchord</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[CShap]]></category>
		<category><![CDATA[netsoft]]></category>

		<guid isPermaLink="false">http://linnchord.net/2004/04/css%e8%ae%be%e8%ae%a1%e5%99%a8%e4%b9%8b%e6%b5%81%e7%a8%8b/</guid>
		<description><![CDATA[最近做了一个CSS设计器，主要功能是在web界面上操作设计CSS样式表，目的是方便用户自定义系统界面。 其实我个人看法这个东西并没有太大必要，对于最终用户来说，一般不熟悉网页制作，是不可能进行这种操作的，而且就系统整体来考虑，也不应该给用户这种权限。另外，相对于本来就比较紧张时间资源来讲，花这么多时间，实现这种用户需求优先度较低的功能，实在不合算&#8230;&#8230; 奈何项目经理雄心勃勃，在大而全的方针指导下，不得不做啊。 月初就作的差不多，来总结一下吧 流程再简单说明一下]]></description>
			<content:encoded><![CDATA[<p>最近做了一个CSS设计器，主要功能是在web界面上操作设计CSS样式表，目的是方便用户自定义系统界面。 </p>
<p>其实我个人看法这个东西并没有太大必要，对于最终用户来说，一般不熟悉网页制作，是不可能进行这种操作的，而且就系统整体来考虑，也不应该给用户这种权限。另外，相对于本来就比较紧张时间资源来讲，花这么多时间，实现这种用户需求优先度较低的功能，实在不合算&hellip;&hellip; </p>
<p>奈何项目经理雄心勃勃，在大而全的方针指导下，不得不做啊。 </p>
<p>月初就作的差不多，来总结一下吧 </p>
<p><img src="http://linnchord.net/upload/x2blog/img/cssflow.gif" alt="" /> </p>
<p>流程再简单说明一下 </p>
]]></content:encoded>
			<wfw:commentRss>http://linnchord.net/archives/132.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

