前一阵子抽了一些时间看了一下缩水版的DNN(starter kit)---- [从二十四画生那里请教的DNN的学习方法]。
其中portal的用户配置文件portalCfg.xml还有该文件的操作类portalCfg.vb是实现灵活页面布局的关键。一开始觉得写操作类的portalCfg.vb文件很难,而且那么长的代码文件差不多2k多行,仔细看portalCfg.vb文件的头部包含这样的注释 :

ASP.NET Portal starter Kit ----之页面配置文件'------------------------------------------------------------------------------
ASP.NET Portal starter Kit ----之页面配置文件'
 <autogenerated>
ASP.NET Portal starter Kit ----之页面配置文件'
     This code was generated by a tool.
ASP.NET Portal starter Kit ----之页面配置文件'
     Runtime Version: 1.0.3705.209
ASP.NET Portal starter Kit ----之页面配置文件'
ASP.NET Portal starter Kit ----之页面配置文件'
     Changes to this file may cause incorrect behavior and will be lost if 
ASP.NET Portal starter Kit ----之页面配置文件'
     the code is regenerated.
ASP.NET Portal starter Kit ----之页面配置文件'
 </autogenerated>
ASP.NET Portal starter Kit ----之页面配置文件'
------------------------------------------------------------------------------

 

因为对XML了解不深,查找一些资料才发现原来portalCfg.vb文件根本不用手写,用生成就可以了,无论是xml或config文件都可。
随便找简单的几行代码先试试
建立一个sample.xml 代码如下

ASP.NET Portal starter Kit ----之页面配置文件<?xml version="1.0" encoding="utf-8" ?> 
ASP.NET Portal starter Kit ----之页面配置文件
<SiteConfiguration>
ASP.NET Portal starter Kit ----之页面配置文件    
<Module ModuleId="1" ModuleTitle="快速連結" EditRoles="Admins;" ModuleDefId="8" PaneName="LeftPane" CacheTimeout="0" ModuleOrder="1" ShowMobile="false" />
ASP.NET Portal starter Kit ----之页面配置文件    
<Module ModuleId="2" ModuleTitle="歡迎使用入口網站入門套件 (Portal Starter Kit)" EditRoles="Admins;" ModuleDefId="5" PaneName="ContentPane" CacheTimeout="0" ModuleOrder="1" ShowMobile="true" />
ASP.NET Portal starter Kit ----之页面配置文件
</SiteConfiguration>

然后在VS2003 里面 按mouse右键 --〉生成架构 你会发现项目中会多出一个 sample.xsd的文件而且你的portalCfg.xml的文件也变成如下
ASP.NET Portal starter Kit ----之页面配置文件<?xml version="1.0" encoding="utf-8"?>
ASP.NET Portal starter Kit ----之页面配置文件
<SiteConfiguration xmlns="http://tempuri.org/sample.xsd">
ASP.NET Portal starter Kit ----之页面配置文件    
<Module ModuleId="1" ModuleTitle="快速連結" EditRoles="Admins;" ModuleDefId="8" PaneName="LeftPane" CacheTimeout="0" ModuleOrder="1" ShowMobile="false" />
ASP.NET Portal starter Kit ----之页面配置文件    
<Module ModuleId="2" ModuleTitle="歡迎使用入口網站入門套件 (Portal Starter Kit)" EditRoles="Admins;" ModuleDefId="5" PaneName="ContentPane" CacheTimeout="0" ModuleOrder="1" ShowMobile="true" />
ASP.NET Portal starter Kit ----之页面配置文件
</SiteConfiguration>

portal.xsd的代码
ASP.NET Portal starter Kit ----之页面配置文件<?xml version="1.0"?>
ASP.NET Portal starter Kit ----之页面配置文件
<xs:schema id="SiteConfiguration" targetNamespace="http://tempuri.org/sample.xsd" xmlns:mstns="http://tempuri.org/sample.xsd" xmlns="http://tempuri.org/sample.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" attributeFormDefault="qualified" elementFormDefault="qualified">
ASP.NET Portal starter Kit ----之页面配置文件  
<xs:element name="SiteConfiguration" msdata:IsDataSet="true" msdata:Locale="zh-CN" msdata:EnforceConstraints="False">
ASP.NET Portal starter Kit ----之页面配置文件    
<xs:complexType>
ASP.NET Portal starter Kit ----之页面配置文件      
<xs:choice maxOccurs="unbounded">
ASP.NET Portal starter Kit ----之页面配置文件        
<xs:element name="Module">
ASP.NET Portal starter Kit ----之页面配置文件          
<xs:complexType>
ASP.NET Portal starter Kit ----之页面配置文件            
<xs:attribute name="ModuleId" form="unqualified" type="xs:string" />
ASP.NET Portal starter Kit ----之页面配置文件            
<xs:attribute name="ModuleTitle" form="unqualified" type="xs:string" />
ASP.NET Portal starter Kit ----之页面配置文件            
<xs:attribute name="EditRoles" form="unqualified" type="xs:string" />
ASP.NET Portal starter Kit ----之页面配置文件            
<xs:attribute name="ModuleDefId" form="unqualified" type="xs:string" />
ASP.NET Portal starter Kit ----之页面配置文件            
<xs:attribute name="PaneName" form="unqualified" type="xs:string" />
ASP.NET Portal starter Kit ----之页面配置文件            
<xs:attribute name="CacheTimeout" form="unqualified" type="xs:string" />
ASP.NET Portal starter Kit ----之页面配置文件            
<xs:attribute name="ModuleOrder" form="unqualified" type="xs:string" />
ASP.NET Portal starter Kit ----之页面配置文件            
<xs:attribute name="ShowMobile" form="unqualified" type="xs:string" />
ASP.NET Portal starter Kit ----之页面配置文件          
</xs:complexType>
ASP.NET Portal starter Kit ----之页面配置文件        
</xs:element>
ASP.NET Portal starter Kit ----之页面配置文件      
</xs:choice>
ASP.NET Portal starter Kit ----之页面配置文件    
</xs:complexType>
ASP.NET Portal starter Kit ----之页面配置文件  
</xs:element>
ASP.NET Portal starter Kit ----之页面配置文件
</xs:schema>

然后打开sample.xsd文件 --〉在数据集模式下面按mouse右键--〉生成数据集   sample.vb代码就出来了。
ASP.NET Portal starter Kit ----之页面配置文件'------------------------------------------------------------------------------
ASP.NET Portal starter Kit ----之页面配置文件'
 <autogenerated>
ASP.NET Portal starter Kit ----之页面配置文件'
     This code was generated by a tool.
ASP.NET Portal starter Kit ----之页面配置文件'
     Runtime Version: 1.1.4322.573
ASP.NET Portal starter Kit ----之页面配置文件'
ASP.NET Portal starter Kit ----之页面配置文件'
     Changes to this file may cause incorrect behavior and will be lost if 
ASP.NET Portal starter Kit ----之页面配置文件'
     the code is regenerated.
ASP.NET Portal starter Kit ----之页面配置文件'
 </autogenerated>
ASP.NET Portal starter Kit ----之页面配置文件'
------------------------------------------------------------------------------
ASP.NET Portal starter Kit ----之页面配置文件

ASP.NET Portal starter Kit ----之页面配置文件
Option Strict Off
ASP.NET Portal starter Kit ----之页面配置文件
Option Explicit On
ASP.NET Portal starter Kit ----之页面配置文件
ASP.NET Portal starter Kit ----之页面配置文件
Imports System
ASP.NET Portal starter Kit ----之页面配置文件
Imports System.Data
ASP.NET Portal starter Kit ----之页面配置文件
Imports System.Runtime.Serialization
ASP.NET Portal starter Kit ----之页面配置文件
Imports System.Xml
ASP.NET Portal starter Kit ----之页面配置文件
ASP.NET Portal starter Kit ----之页面配置文件
ASP.NET Portal starter Kit ----之页面配置文件
<Serializable(),  _
ASP.NET Portal starter Kit ----之页面配置文件 System.ComponentModel.DesignerCategoryAttribute(
"code"),  _
ASP.NET Portal starter Kit ----之页面配置文件 System.Diagnostics.DebuggerStepThrough(),  _
ASP.NET Portal starter Kit ----之页面配置文件 System.ComponentModel.ToolboxItem(
true)>  _

这样的话就方便了。用这种方法重新生成portalCfg.vb 发现生成的代码也只比原来的少了几个简单的方法而已。 好了也算是学习DNN的一个小小的收获。贴出来如有不妥请大家指教。

相关链接:
asp.net Portal Starter kit----改造Portal的Html文本编辑器

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-03
  • 2022-01-01
  • 2021-08-05
  • 2021-12-24
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-08-31
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-05
  • 2022-12-23
相关资源
相似解决方案