惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
Stack Overflow Blog
Stack Overflow Blog
Hugging Face - Blog
Hugging Face - Blog
博客园_首页
T
The Blog of Author Tim Ferriss
博客园 - 叶小钗
N
Netflix TechBlog - Medium
腾讯CDC
C
Check Point Blog
P
Proofpoint News Feed
Engineering at Meta
Engineering at Meta
GbyAI
GbyAI
S
SegmentFault 最新的问题
F
Fortinet All Blogs
美团技术团队
U
Unit 42
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 司徒正美
F
Full Disclosure
Recorded Future
Recorded Future
D
DataBreaches.Net
博客园 - 【当耐特】
Martin Fowler
Martin Fowler
J
Java Code Geeks
I
InfoQ
Y
Y Combinator Blog
A
About on SuperTechFans
AI
AI
爱范儿
爱范儿
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Forbes - Security
Forbes - Security
W
WeLiveSecurity
M
MIT News - Artificial intelligence
雷峰网
雷峰网
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Simon Willison's Weblog
Simon Willison's Weblog
Schneier on Security
Schneier on Security
The GitHub Blog
The GitHub Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
aimingoo的专栏
aimingoo的专栏
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
G
GRAHAM CLULEY
Know Your Adversary
Know Your Adversary
Latest news
Latest news
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
D
Docker
Recent Commits to openclaw:main
Recent Commits to openclaw:main
量子位
V2EX - 技术
V2EX - 技术
Project Zero
Project Zero

博客园 - bestcomy

在OPENSUE 11.3 上安装 sysstat Upload bug in MOSS 2007 / Windows Server 2008 - bestcomy Excel列名转换 Clienside ProgressIndicator - bestcomy - 博客园 ASP.NET MVC 源代码发布! 微软项目组招聘.NET开发人员(北京) 欢迎访问我的新BLOG空间 SharePoint 胡言乱语 你觉得vs.net那些地方让你使用起来很不爽? Include javascript and css dynamically - bestcomy Two ways to get HtmlTextWriter for HTML rendering Get the true value of a calculate field in SharePoint 调用自定义event时需要注意的一个问题 self==top 如何设置AD用户的"用户下次登陆时须更改密码"属性 (LDAP Provider) 微软 and 香烟 Cool!!! Virtual Earth Technology Preview sth about our coding life 还没有Windows Live Messenger的朋友看过来
How to set value for webpart’s properties when I create a new sharepoint template
bestcomy · 2006-10-31 · via 博客园 - bestcomy

When I create a new sharepoint template for my project use, I want to set the value for webpart’s properties as soon as the site created using this template. Adding a list by default is easy after my reading of the great article from http://aspalliance.com/ . I have developed a webpart for list displaying, and I know how to add this webpart in the rootweb by default, but I don’t know how to set value for the webpart’s properties by default. When I open a Onet.xml from one built-in template I got a example as follows:

 1 <AllUsersWebPart WebPartZoneID="Right" WebPartOrder="1">
 2                    <![CDATA[
 3                    <WebPart xmlns="http://schemas.microsoft.com/WebPart/v2" xmlns:iwp="http://schemas.microsoft.com/WebPart/v2/Image">
 4                         <Assembly>Microsoft.SharePoint, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
 5                         <TypeName>Microsoft.SharePoint.WebPartPages.ImageWebPart</TypeName>
 6                         <FrameType>None</FrameType>
 7                         <Title>网站图像</Title>
 8                         <iwp:ImageLink>/_layouts/images/homepage.gif</iwp:ImageLink>
 9                    </WebPart>
10                    ]]>
11                 </AllUsersWebPart>

I believe line 8 is the key of my problem. And now the problem is how to set the iwp prefix. After my reflector of Microsoft.SharePoint.WebPartPages.ImageWebPart, I got some interesting code fragment below:

1 [Guid("20743A06-C4E6-4984-A8A0-918C34353148"), XmlRoot(Namespace="http://schemas.microsoft.com/WebPart/v2/Image")]
2 public sealed class ImageWebPart : WebPart, IDesignTimeHtmlProvider, ICellConsumer
3 {
4 //
5 }

Compare xmlns:iwp="http://schemas.microsoft.com/WebPart/v2/Image" to  XmlRoot(Namespace="http://schemas.microsoft.com/WebPart/v2/Image"), I know the answer. my webpart xmlroot is "Microsoft.MCS.HPITeam.Portal.WebParts", so I registered my webpart as following:

<AllUsersWebPart WebPartZoneID="Middle" WebPartOrder="2">
                   
<![CDATA[
                   <WebPart xmlns="http://schemas.microsoft.com/WebPart/v2" xmlns:dtl="Microsoft.MCS.HPITeam.Portal.WebParts">
                        <Assembly>Microsoft.MCS.HPITeam.Portal.WebParts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=541eeb7342aeb9f8</Assembly>
                        <TypeName>Microsoft.MCS.HPITeam.Portal.WebParts.DocumentTopList</TypeName>
                        <FrameType>None</FrameType>
                        <Title>部门动态</Title>
                        <dtl:DocumentLibraryName>部门动态</dtl:DocumentLibraryName>
                        <dtl:DisplayTitle>部门动态</dtl:DisplayTitle>
                        <dtl:DisplayWidth>500</dtl:DisplayWidth>
                   </WebPart>
                   
]]>
                
</AllUsersWebPart>