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開發時註意的問題的更多相关文章

  1. 【開發時,應注意事項】 vendor tools 無法 work 時,怎麼辦?

    遇到 vendor tools 無法 work 時, 最好的方法直接請 vendor 來, 為什麼呢? 因為 tool 可能 有版本的問題, 譬如: vendor tool A tool 在 buil ...

  2. 「Ionic」使用chrom時的跨域問題

    前言:在angularjs請求數據時,會遇到跨域問題,解決辦法有很多,但是都不是我想要的(很多人云亦云,都解決不了問題).如果你只是想在本機測試使用,可以參考如下設置.   具體辦法: 1.在电脑上新 ...

  3. 修改windows系統下xampp中apache端口被其他程式占用的問題

    windows 7安裝後啟動xampp, 提示port 443 被其他程式占用. 網上查找解決方案: http://stackoverflow.com/questions/21182512/how-t ...

  4. Delphi APP 開發入門(一)重生的 Delphi

    Delphi APP 開發入門(一)重生的 Delphi 分享: Share on facebookShare on twitterShare on google_plusone_share   閲讀 ...

  5. .net批量上傳Csv檔資料應用程序開發總結

    應用環境:visual studio 2010開發工具,Database為Sql2008以上版本 最近在生產環境中需要開發一款應用程式,上傳電子檔(.csv)資料至Database 最初方案: 以tx ...

  6. Delphi APP 開發入門(五)GPS 定位功能

    Delphi APP 開發入門(五)GPS 定位功能 分享: Share on facebookShare on twitterShare on google_plusone_share   閲讀次數 ...

  7. IDEA開發 java web 初步

    作爲一個小白,我也不知道爲啥同學們喜歡用IDEA開發,而不選擇eclipse,但是在項目學習中eclipse卻真的多次出現問題,無奈之下,本人也安裝了一個IDEA作爲學習使用.參考了博客開始使用這個工 ...

  8. ASP.NET MVC 開發心得分享 (21):Routing 觀念與技巧

    ASP.NET MVC 預設在 Global.asax 所定義的 RegisterRoutes 方法中可以輕易的定義你希望擁有的網址格式,嚴格上來講這並非 ASP.NET MVC 的專利,而是從 AS ...

  9. Bear 實驗室: 什麼是Git flow ? 如何在SourceTree使用Git flow管理開發!

      http://www.takobear.tw/12/post/2014/02/bear-git-flow-sourcetreegit-flow.html     Bear 實驗室: 什麼是Git ...

随机推荐

  1. Spring中Beans的自动装配概述

    以下内容引用自http://wiki.jikexueyuan.com/project/spring/beans-autowiring.html: 在之前的做法上会参照这样的顺序:1.使用<bea ...

  2. windows redis 服务安装坑

    环境 winserver 2012 最新版的redis:3.0.503 redis-server.exe   --service-install   redis.windows.conf    --m ...

  3. MapReduce编程实战之“调试”和&quot;调优&quot;

    本篇内容 在上一篇的"初识"环节,我们已经在本地和Hadoop集群中,成功的执行了几个MapReduce程序,对MapReduce编程,已经有了最初的理解. 在本篇文章中,我们对M ...

  4. XSS学习分支图

    转载请注明出处:http://blog.csdn.net/cym492224103 watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2 ...

  5. VisualSVN Server 改动用户password

    VisualSVN Server是很方便好用的SVNserver端软件.但有个问题,你在server端创建了usernamepassword后,用户无法自己改动password.据说VisualSVN ...

  6. plsql 无需配置客户端连接.

    plsql 无需配置客户端连接. (DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.0.5)(PORT=1521)))(C ...

  7. [Python-MATLAB] 在Python中调用MATLAB的API

    可以参考官方的说明文档: http://cn.mathworks.com/help/matlab/matlab_external/get-started-with-matlab-engine-for- ...

  8. 如何动态地给vSphere虚拟机模板注入信息

    在做vSphere自动化安装过程中,遇到这样一个需求:将vCenter Server做成模板,在给用户自动化装好vSphere后, 下载vCenter Server模板并启动虚拟机,然后将vCente ...

  9. Win8下怎样安装Win7 or Win7下怎样安装win8?

    预计非常多人可能会用U盘安装工具去去做双系统的安装(Win8下安装Win7, Win7下安装Win8).可是在安装过程中你 会发现一个问题:win7下安装win8,提示你mbr硬盘格式不能安装win8 ...

  10. gradle配置远程仓库(以及使用本地maven仓库)

    allprojects{ repositories { mavenLocal() def REPOSITORY_URL = 'http://maven.aliyun.com/nexus/content ...