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. IntelliJ IDEA简体中文专题教程

    说明:应该是全网最全的中文教程了,包括一些常用的快捷键和配置等等.是的,我已经转IntelliJ IDEA了. 来自judasn的IntelliJ IDEA简体中文专题教程: https://gith ...

  2. Base64的空格 + 问题...

    BASE64  通过url传递到后台 加号变空格的处理方法 解决方法: 前台处理:str.replace("+", "%2B"); (错误) <scrip ...

  3. mysql 同样内容的字段合并为一条的方法

    从两个表中内联取出的数据,当中category_name字段有同样内容,想将具有同样内容的字段进行合并,将amount字段进行加法运算,变成下表中的内容 url=http%3A%2F%2Fdev.my ...

  4. react jsx 数组变量的写法

    1.通过 map 方法 var students = ["张三然","李慧思","赵思然","孙力气","王萌 ...

  5. ime-mode:disabled (用css实现关闭文本框输入法)

    css 之 ime-mode语法:ime-mode : auto | active | inactive | disabled取值:auto : 默认值.不影响ime的状态.与不指定 ime-mode ...

  6. WCF 内存入口检查失败 Memory gates checking failed

    在做JC系统时,出现这样的错误: 出现该错误信息的原因是因为WCF服务激活之前,系统应该具有的最小内存量不足config文件中设置的百分比.我是在本机调试的时候出现的. 解决方法:        关闭 ...

  7. vim字符串替换命令

    呜呜老是忘. 这里记录一下,仅仅记录当中日经常使用的最多的命令. :%s/str1/str2/g   替换每一行中全部str1为str2 经常使用! :s/str1/str2/g 替换当前行全部str ...

  8. Using Virtual Serial Ports on Linux (Ubuntu)

    http://www.xappsoftware.com/wordpress/2013/10/07/using-virtual-serial-ports-on-linux-ubuntu/?goback= ...

  9. 项目记录26--unity-tolua框架 View03-UIManager.lua

    做为程序员要懂得假设保持健康,对电脑时间太长非常easy眼花,得脖子病,腰都疼,这星期六日组团到康宁去了,哈哈. 一个字"疼"!!!! 废话不多少,把UIManager.lua个搞 ...

  10. 多线程-----Thread类与Runnable接口的区别

    第一个继承Thread类来实现多线程,其实是相当于拿出三件事即三个卖早餐10份的任务分别分给三个窗口,他们各做各的事各卖各的早餐各完成各的任务,因为MyThread继承Thread类,所以在newMy ...