Sharepoint中WebPart開發時註意的問題
1. 怎麼樣在WebPart中使用Sharepoint控件?
要在webpart中使用sharepoint控件必須先引用Microsoft.SharePoint.WebControls命名空間,如你現開發的是QuickPart,你需要在ascx文件中加入sharepoint控件,怎麼實現?
a. 在asxc文件中加入如下引用
%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
b. 在asxc文件中加入一個人員選擇框控件
<SharePoint:PeopleEditor id="upuid" runat="server" SelectionSet="User" ValidatorEnabled="true" AllowEmpty = "true" MultiSelect = "false" Width="150" />
後端代碼取得你所選擇的帳號的方法是:
upuid.CommaSeparatedAccounts;
c. 在asxc文件中加入一個日期選擇控件
<SharePoint:DateTimeControl id="update1" runat="server" DateOnly="true" CssClassTextBox="fr_date" />
後端代碼取得你所選擇的日期的方法是:
string tmp_udpate1 = update1.SelectedDate.ToString("yyyy-MM-dd 00:00:00");
if (update1.IsDateEmpty) tmp_udpate1 = "";
d. 其它控件可以參數SDK說明......
2. 在開發Webpart的時候怎麼樣控制其樣式,使其樣式會跟著sharepoint網站的布景主題的改變而改變
a. 先來看看表單界面的樣式控制
<table class="ms-formtable" style="margin-top: 5px;" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td class="fr_td1 ms-formlabel">上傳人:</td>
<td class="fr_td2 ms-formbody">
<SharePoint:PeopleEditor id="upuid" runat="server"
SelectionSet="User"
ValidatorEnabled="true"
AllowEmpty = "true"
MultiSelect = "false"
Width="150"
/>
</td>
<td class="fr_td1 ms-formlabel">上傳日期:</td>
<td class="fr_td2 ms-formbody">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td>
<SharePoint:DateTimeControl id="update1" runat="server" DateOnly="true" CssClassTextBox="fr_date" />
</td>
<td>
~
</td>
<td>
<SharePoint:DateTimeControl id="update2" runat="server" DateOnly="true" CssClassTextBox="fr_date" />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="fr_td1 ms-formlabel">單位:</td>
<td class="fr_td2 ms-formbody">
<asp:DropDownList ID="webtitle" runat="server"></asp:DropDownList>
</td>
<td class="fr_td1 ms-formlabel">格式:</td>
<td class="fr_td2 ms-formbody">
<asp:CheckBoxList runat="server" ID="ext" RepeatDirection="Horizontal" RepeatColumns="5"></asp:CheckBoxList>
</td>
</tr>
<tr>
<td class="ms-formlabel"><table></table></td>
<td class="ms-formlabel" colspan="3">
<table></table>
</td>
</tr>
</table>
其中表單的Table使用樣式ms-formtable
表單的說明文字所在TD使用樣式 ms-formlabel
表單的控件所在TD使用樣式 ms-formbody
按鈕使用樣式ms-ButtonHeightWidth
b. 再來看看列表所使用的樣式
<asp:GridView ID="fileList" runat="server" AutoGenerateColumns="false" Width="100%" CssClass="ms-listviewtable">
<HeaderStyle CssClass="ms-viewheadertr" Height="25" />
<AlternatingRowStyle CssClass="ms-alternating" Height="23" />
<RowStyle CssClass="" Height="23" />
<Columns>
<asp:TemplateField HeaderText="NO" HeaderStyle-CssClass="ms-vh2 fr_header" ItemStyle-CssClass="ms-vb2 fr_item1">
<ItemTemplate>
<%# Container.DataItemIndex+1 %>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="UPUID" HeaderText="上傳人" HeaderStyle-CssClass="ms-vh2 fr_header" ItemStyle-CssClass="ms-vb2 fr_item3"/>
<asp:BoundField DataField="UPdate" HeaderText="週期" HtmlEncode="false" DataFormatString="{0:yyyy-MM-dd}" HeaderStyle-CssClass="ms-vh2 fr_header" ItemStyle-CssClass="ms-vb2 fr_item2" />
<asp:BoundField DataField="upcount" HeaderText="檔案量(上傳)" HeaderStyle-CssClass="ms-vh2 fr_header" ItemStyle-CssClass="ms-vb2 fr_item3"/>
<asp:TemplateField HeaderText="檔案名稱" HeaderStyle-CssClass="ms-vh2 fr_header" ItemStyle-CssClass="ms-vb2 fr_item4">
<ItemTemplate>
<%# GetFiles(Eval("Update")) %>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
其中列表的Table使用樣式ms-listviewtable
表題的TR使用樣式ms-viewheadertr
表題的TD使用樣式ms-vh2
單數行TR使用樣式ms-alternating
主體部份的TD使用樣式ms-vb2
這樣開發出來的WebPart就會跟著網站主題的改變而改變,如下圖所示:
布景主題為"預設布景主題"時的顯示樣式:

布景主題為"柑橘"時的顯示樣式:

3. SPQuery參數說明:
- ViewAttributes
a. Scope='Default' : 只顯示指定文件夾下的項目及子文件夾
b. Scope='FilesOnly' : 只顯示指定文件夾下的項目
c. Scope='Recursive' : 顯示所有項目,不顯示文件夾
d. Scope='RecursiveAll' : 顯示所有項目和所有子文件夾 - RowLimit
返回多少條記錄 - ListItemCollectionPosition
Sharepoint中WebPart開發時註意的問題的更多相关文章
- 【開發時,應注意事項】 vendor tools 無法 work 時,怎麼辦?
遇到 vendor tools 無法 work 時, 最好的方法直接請 vendor 來, 為什麼呢? 因為 tool 可能 有版本的問題, 譬如: vendor tool A tool 在 buil ...
- 「Ionic」使用chrom時的跨域問題
前言:在angularjs請求數據時,會遇到跨域問題,解決辦法有很多,但是都不是我想要的(很多人云亦云,都解決不了問題).如果你只是想在本機測試使用,可以參考如下設置. 具體辦法: 1.在电脑上新 ...
- 修改windows系統下xampp中apache端口被其他程式占用的問題
windows 7安裝後啟動xampp, 提示port 443 被其他程式占用. 網上查找解決方案: http://stackoverflow.com/questions/21182512/how-t ...
- Delphi APP 開發入門(一)重生的 Delphi
Delphi APP 開發入門(一)重生的 Delphi 分享: Share on facebookShare on twitterShare on google_plusone_share 閲讀 ...
- .net批量上傳Csv檔資料應用程序開發總結
應用環境:visual studio 2010開發工具,Database為Sql2008以上版本 最近在生產環境中需要開發一款應用程式,上傳電子檔(.csv)資料至Database 最初方案: 以tx ...
- Delphi APP 開發入門(五)GPS 定位功能
Delphi APP 開發入門(五)GPS 定位功能 分享: Share on facebookShare on twitterShare on google_plusone_share 閲讀次數 ...
- IDEA開發 java web 初步
作爲一個小白,我也不知道爲啥同學們喜歡用IDEA開發,而不選擇eclipse,但是在項目學習中eclipse卻真的多次出現問題,無奈之下,本人也安裝了一個IDEA作爲學習使用.參考了博客開始使用這個工 ...
- ASP.NET MVC 開發心得分享 (21):Routing 觀念與技巧
ASP.NET MVC 預設在 Global.asax 所定義的 RegisterRoutes 方法中可以輕易的定義你希望擁有的網址格式,嚴格上來講這並非 ASP.NET MVC 的專利,而是從 AS ...
- Bear 實驗室: 什麼是Git flow ? 如何在SourceTree使用Git flow管理開發!
http://www.takobear.tw/12/post/2014/02/bear-git-flow-sourcetreegit-flow.html Bear 實驗室: 什麼是Git ...
随机推荐
- CSS 居中 可随着浏览器变大变小而居中
关键代码: 外部DIV使用: text-align:center; 内部DIV使用: margin-left:auto;margin-right:auto 例: <div style=" ...
- Bootstrap全局CSS样式之button和图片
.btn-default--button的默认样式. .btn-primary--button的首选样式: .btn-success--button的成功样式: .btn-info--button的一 ...
- CSS3中transition-duration參数对hover前后两种过渡时间的影响
transition-duration这个參数是设置过渡时间的,将transition-duration放在哪个类中.那么在这个类被启用时就会依照transition-duration设定的时间来过渡 ...
- ios9定位服务的app进入后台三分钟收不到经纬度,应用被挂起问题及解决方式
原来定位服务是10分钟收不到定位信息就挂起定位,如今变为最短3分钟,预计都是为了省电吧. 仅仅要你开启应用的后台定位,而且10分钟有一次定位,那么苹果就不会关闭你的线程.如今变成3分钟.若你的应用开启 ...
- Indri和Terrier搜索引擎的使用
介绍 Indri和Terrier都是开源的搜索引擎,当中Indri作为Lemur项目的一个重要部分,具有强大的查询接口,易建索引,可扩展,高效率等长处.能够在SourceForge Lemur Pro ...
- 使用MegaCli查看raid信息
LSI SAS based MegaRAID driver http://www.lsi.com/downloads/Public/Nytro/downloads/Nytro%20XD/MegaCli ...
- [转载]saltstack master配置文件中文翻译
原文出处:http://blog.coocla.org/301.html Salt系统的配置是令人惊讶的简单,对于salt的两个系统都有各自的配置文件,salt-master是通过一个名为master ...
- centos6.3升级python至2.7.5
centos6.3自带的python版本是2.6.6,有时候需要升级到2.7.这里记录一下升级过程,方便查阅.实际上是转载自http://flyingdutchman.iteye.com/blog/1 ...
- reviews of learn python3 the hard way
Almost every time,I try my best to write a long review of the book I have read. But this time I want ...
- js弹出QQ对话框在线交谈
<div style="position:absolute; top:110px; right:220px; z-index:2;"> <a target=&qu ...