WebPart of MOSS 2007

new project
location and new name(EWAPlus)
Solution\Property\Application
assembly name and default namespace(IWSTech.BMC.Inventory.EWAPlus, IWSTech.BMC.Inventory)
Change the class and file name

Solution\Property\Signing
Strong naming project
Solution\Property\Build Events\Post-build event
Adding .dll to GAC

Safe controls
<SafeControl Assembly="IWSTech.BMC.Inventory.EWAPlus, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1c051731a1a827ae" Namespace="IWSTech.BMC.Inventory" TypeName="*" Safe="True" AllowRemoteDesigner="True"/>

http://youngmoss07name/_layouts/newdwp.aspx
Add the .webpart file to site gallery
export .webpart file to your project
Add the WebPart to page

OnInit  初始化,加载相关配置文件  (如WebPart任务面板上的属性,样式等配置信息)
LoadViewState 返回先前最后一次被处理的状态 (如webpart是展现,隐藏还是关闭)
CreateChildControls  创建WebPart UI ,通过Controls.Add()方法装载Web 控件 (Note:当Webpart是第一次展现的时候CreateChildControls方法发生在OnLoad方法之前,而经过一次postback之后,它发生在OnLoad方法之后)
OnLoad 

从数据库或者其他系统重新获取要展现的数据 (如获取数据库连接)

User-Generated Events 响应用户生成事件 (如Button Click)
RendenContents 生成 html output,实现最终的UI展现 (由HTMLTextWriter class 来实现) 
SaveViewState 保存控件状态 (ViewState 被序列化之后保存在一个hidden field 里)
Dispose 从内存中移除对象,释放临界资源 (如释放数据库连接)
OnUnLoad 最终完成内存清除工作

posted @ 2008-02-23 09:17  Andy Yang  阅读(426)  评论(0编辑  收藏  举报