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 ...
随机推荐
- Ubuntu 16.04通过Snap安装应用程序
16.04LTS可以说是一个不寻常的5年支持版本,同时也带来了Snap应用,并通过Snap可以安装众多的软件包.需要注意的是,Snap是一个全新的软件包架构,但是同样也比其它的软件包大很多. 简单的安 ...
- html页面中拍照和上传照片那些事儿(二)
本文为原创,转载请注明出处: cnzt 文章:cnzt-p http://www.cnblogs.com/zt-blog/p/6895352.html 本文主要说下iOS上传的照片在安卓机 ...
- MongoDB下配置用户权限
MongoDB默认设置为无权限訪问限制 注:研究成果基于Windows平台 在部署mongodb成功后.进入控制台: 输入命令:mongod use admin,你会发现该DB下包括了一个syste ...
- Effective C++ 条款六 若不想使用编译器自动生成的函数,就该明确拒绝
class HomeForSale //防止别人拷贝方法一:将相应的成员函数声明为private并且不予实现 { public: private: HomeForSale(const HomeForS ...
- cin,和几个get函数的用法
1.cin.get(字符变量名):用来接收字符 ch = cin.get(); cin.get(ch); 以上两者均可以 2.cin.get(字符数组名,接收字符数目)用来接收一行字符串,可以接收空格 ...
- Java经常使用类及其经常用法
1.ArrayList java.util.ArrayList<E> add(E e) //插入尾部 add(int index, E element) remove(int index) ...
- android-custom-tab-with-viewpager
https://github.com/eltld/android-custom-tab-with-viewpager
- <十二>读<<大话设计模式>>之状态模式
对于状态模式,<<大话设计模式>>是以人从上班到下班到加班的状态来展开讲述的.状态模式事实上就是某一个对象在某个过程或者时间的一个状态记录,可是这个状态的顺序不能发生变化.在程 ...
- asp.net+access实现DropDownList与RadDatePicker同步筛选
这里没有使用SqlServer是因为老师要求使用access. 前台代码 <table style="margin:auto"> <tr><td cl ...
- hdfs 3种 通讯协议
http://hadoop.apache.org/docs/r1.0.4/cn/hdfs_design.html 通讯协议 所有的HDFS通讯协议都是建立在TCP/IP协议之上.客户端通过一个可配置的 ...