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 ... 
随机推荐
- IntelliJ IDEA配置Tomcat/Jetty运行Web项目
			一.使用Maven的POM引入插件的形式: 这种方式只需在POM中引入Tomcat/Jetty的插件即可运行.参考:http://www.cnblogs.com/EasonJim/p/6687272. ... 
- 【Mybatis】 Mybatis在xml文件中处理大于号小于号的方法【问题】
			处理大于小于号的方法: https://www.cnblogs.com/winner-0715/p/6132755.html 第一种方法:用转义字符把">"和"&l ... 
- Tar压缩文件
			[root@test /root]# tar [-zxcvfpP] filename [root@test /root]# tar -N 'yyyy/mm/dd' /path -zcvf targ ... 
- nginx配置初步
			nginx配置初步 1,切换至nginx目录,找到配置文件目录 cd /etc/nginx/conf.d 2,拷贝一份conf文件 sudo cp default.conf head.conf 3,进 ... 
- Netty3 源代码分析 - NIO server绑定过程分析
			Netty3 源代码分析 - NIO server绑定过程分析 一个框架封装的越好,越利于我们高速的coding.可是却掩盖了非常多的细节和原理.可是源代码可以揭示一切. 服务器端代码在指定 ... 
- Type cannot use 'try' with exceptions disabled
			cannot use ‘throw’ with exceptions disabled 在为 DragonBonesCPP/refactoring 的 cocos2d-x-3.2 demo 增加 An ... 
- vimrc 避免中文乱码配置
			et smsyntax onset ts=4set sts=4set sw=4set hlsearchset rulerset backspace=indent,eol,startset encodi ... 
- Python - 学习参考资料
			官方reference: 1.Numpy的API Reference https://docs.scipy.org/doc/numpy/reference/routines.html 2.SciPy的 ... 
- 常用shell命令的写法
			这并不是教人怎么进行shell编程的文章,只是韦哥在工作中用到的一些简单脚本的写法.因为有些命令即使用过几次了,再次使用时仍然写不对,需要man来看下或者需要google,你也可以理解为对命令的理解不 ... 
- 3144: [Hnoi2013]切糕
			3144: [Hnoi2013]切糕 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 1526 Solved: 827[Submit][Status] ... 
