Pat’s .Net and Sharepoint Blog
In the Microsoft Sharepoint and .Net Trenches

Minimal Sharepoint Application Page Code

July 26th, 2008 . by <Patrick/>

Below is some code to get you started on creating your own Sharepoint Application Page so that it looks just like the built in ones!

<%@ Assembly Name=”Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c”%>
<%@ Assembly Name=”CheckInAll, Version=1.0.0.0, Culture=neutral, PublicKeyToken=70b886b56e89f448″  %>
<%@ Page Language=”VB” MasterPageFile=”~/_layouts/application.master” Inherits=”VSeWSS.CheckInAll.CheckIn” %>
<asp:Content ID=”PageTitle” contentplaceholderid=”PlaceHolderPageTitle” runat=”server”>
 Check-In: All Documents
</asp:Content>

<asp:Content ID=”PageTitleInTitleArea” runat=”server”
             contentplaceholderid=”PlaceHolderPageTitleInTitleArea” >
 Check-In: All Documents
</asp:Content>

<asp:Content ID=”Main” contentplaceholderid=”PlaceHolderMain” runat=”server”>
<table>
<tr>
  <td class=”ms-descriptiontext” valign=”top”>
    <table border=”0″ cellpadding=”1″ cellspacing=”0″ width=”100%”>
     <tr>
      <td class=”ms-sectionheader” style=”padding-top: 4px;” height=”22″ valign=”top”>
        <H3 class=”ms-standardheader”>
                                Check-In Document
         </H3>

      </td>
     </tr>

     <tr>
      <td class=”ms-descriptiontext ms-inputformdescription”>
      �
                   Add comments to all the documents you are checking in
 �
      </td>
      <td><IMG SRC=”/_layouts/images/blank.gif” width=8 height=1 alt=”"></td>
     </tr>

     <tr>
      <td><IMG SRC=”/_layouts/images/blank.gif” width=150 height=19 alt=”"></td>
     </tr>

    </table>
   </td>
   <td class=”ms-authoringcontrols ms-inputformcontrols” valign=”top”
   align=”left” >
    <table border=”0″ width=”100%” cellspacing=”0″ cellpadding=”0″>
     <tr>

      <td width=”9px”><IMG SRC=”/_layouts/images/blank.gif” width=9 height=7 alt=”"></td>

      <td><IMG SRC=”/_layouts/images/blank.gif” width=150 height=7 alt=”"></td>

      <td width=”10px”><IMG SRC=”/_layouts/images/blank.gif” width=10 height=1 alt=”"></td>

     </tr>
     <tr>
      <td />
      <td class=”ms-authoringcontrols”>
       <table class=”ms-authoringcontrols” border=”0″ width=”100%” cellspacing=”0″ cellpadding=”0″>
       �
  �
     <tr id=”ctl00_PlaceHolderMain_ctl01_ctl02_tablerow1″>
      <td class=”ms-authoringcontrols” colspan=”2″ nowrap>
       <label for=”ctl00_PlaceHolderMain_ctl01_ctl02_InputFile” id=”ctl00_PlaceHolderMain_ctl01_ctl02_LiteralLabelText”>Comments:</label>
      </td>
     </tr>
     <tr id=”ctl00_PlaceHolderMain_ctl01_ctl02_tablerow2″>
      <td><IMG SRC=”/_layouts/images/blank.gif” width=1 height=3 alt=”"></td>
     </tr>
     <!– End Right_Text –>
     <tr id=”ctl00_PlaceHolderMain_ctl01_ctl02_tablerow3″>
      <td width=”11″ ><IMG SRC=”/_layouts/images/blank.gif” width=11 height=1 alt=”"></td>
      <td class=”ms-authoringcontrols” width=”99%”>
      �
                      <TABLE class=”ms-authoringcontrols” width=”100%”>
                    <TR><TD>
                      <SPAN dir=”ltr”>
                      <asp:TextBox runat=”server” Width=”350px” ID=”txtComments” TextMode=”MultiLine” Rows=”5″></asp:TextBox>
                      </SPAN>
                    </TD></TR>
                    </TABLE>
  �
      </td>
     </tr>
    �
     <tr id=”ctl00_PlaceHolderMain_ctl01_ctl02_tablerow5″>
      <td><IMG SRC=”/_layouts/images/blank.gif” width=1 height=6 alt=”"></td>
     </tr>
       </table>
      </td>
      <td width=”10px”><IMG SRC=”/_layouts/images/blank.gif” width=10 height=1 alt=”"></td>
     </tr>

     <tr>
      <td />
      <td><IMG SRC=”/_layouts/images/blank.gif” width=150 height=13 alt=”"></td>
      <td />
     </tr>

    </table>
   </td>
  </tr>

  <tr>
   <td height=”2px” class=”ms-sectionline” colspan=”2″>
   <IMG SRC=”/_layouts/images/blank.gif” width=1 height=1 alt=”">
   </td>
  </tr>
 �
  <tr>
   <td height=”10px” class=”ms-descriptiontext” colspan=”2″>
   <IMG SRC=”/_layouts/images/blank.gif” width=1 height=10 alt=”">
   </td>
  </tr>
  <tr>
   <td colspan=”2″>
    <table cellpadding=”0″ cellspacing=”0″ width=”100%”>
     <colgroup>
      <col width=”99%”>
      <col width=”1%”>
     </colgroup>
     <tr>
      <td>
        </td>
      <td nowrap>
       <asp:Button ID=”btnOK” Text=”OK” Width=”100px” runat=”server” />
       <asp:Button ID=”btnCancel” OnClientClick =”window.location=history.back();” Width=”100px” Text=”Cancel” runat=”server” />
      </td>
     </tr>
    </table>
   </td>
  </tr>
 �
  <tr>
   <td height=”40″ class=”ms-descriptiontext” colspan=”2″>
   <IMG SRC=”/_layouts/images/blank.gif” width=1 height=4 alt=”">
   </td>�
     </tr>
   �
  </td>
 </table>
</asp:Content>


SuperGrid

May 27th, 2008 . by <Patrick/>

Extending the GridView Control The SuperGrid control is an extended version of the ASP.Net GridView Control with some extra features. These features include the following:

  • An option to create a checkbox column and you can use the selectedIndexes property to obtain the selected values
  • A sorting indicator up/down
  • An automatic row count ie 1-10 of 200
  • Custom navigation
  • Row highlighting of any selected rows

I have included a Visual Studio 2005 Solution below along with a SQL Server database backup file that you can restore. I used the code from Dino Esposito’s wonder ful article in MSDN Magazine Extending the GridView Control as a starting point.

The solution includes two projects the SuperGrid which is basically the control and a little web application that makes use of the SuperGrid. The SuperGridSampleApp project includes a folder named db and this folder contains the database backup file called Customers.bak. The project also contains a folder named bll and it is an example on how I would typically create a business layer. I am curious about what other developers think about this technique of building a business layer.

Here is a screenshot of what it looks like:

SuperGrid

Click here to download a zip file with the code


Adding Sharepoint Intellisence to Visual Studio 2005

May 26th, 2008 . by <Patrick/>

Instead of adding the Sharepoint XML schema one file at a time to create your feature.xml files and element manifest files you can also add it to the Visual Studio XML schema cache. Every time Visual Studio loads, it loads the schemas defined in the XML schema cache automatically. 

Steps :

Navigate to:
c:\Program Files\Microsoft Visual Studio 8\Xml\Schemas

Create a new XML file called Sharepoint.xml

Add the following code to the file:
<SchemaCatalog xmlns=”http://schemas.microsoft.com/xsd/catalog”>
  <Schema href=”file://%ProgramFiles%/Common Files/Microsoft Shared/web server extensions/12/TEMPLATE/XML/wss.xsd” targetNamespace=”http://schemas.microsoft.com/sharepoint/” />
</SchemaCatalog>

Save the file If Visual Studio is already open close it then re-open it. This will reload all the schemas files including the one you just added

Now try creating a new feature.xml file

Specify the sharepoint namespace for the feature.xml file

XML Schema 

Now the intellisense should work!

 XML Schema


Where did my solution go in Visual Studio 2005!?

May 20th, 2008 . by <Patrick/>

Not sure if you’ve had this problem but sometimes in Visual Studio 2005 I lose the solution in solution explorer. To fix this problem go into Tools -> Options -> (Make sure Show all settings is checked) Projects and Solutions -> General and make sure that the “Always show Solution” is checked.

 Show Solution

 


Creating a Custom Action and Custom Sharepoint Application Page using VSEWSS 1.1

February 26th, 2008 . by <Patrick/>

I love the deploy functionality built in to Visual Studio Extensions for Windows Sharepoint Services. It makes creating solution files so much easier. Creating manifest.xml files, using makecab.exe blah blah blah - what a headache! With every blog out there someone has a different way of creating it ie using ms build some third party tool from CodePlex, using .bat and .cmd files - Brutal!!

Anyways all was fine and dany I was pumping out webparts, lists, custom fields etc but then I tried deploying a custom application page and a custom action.

I created the following folder structure Template/Layouts/CustomAppPage and then put my .aspx file there but when deploying the solution VS was not copying the file to the 12 hive Layouts directory. When I checked out the WSP view my features and files were not there.

After a long time I finally realized what I was doing wrong. I first created my aspx file, feature and elements files in one project and then just copied them and added them to my new Empty Sharepoint solution.

What you need to always do is in Solution Explorer right click and then Add Item

For Application pages use the Template item for Elements.xml files use the Module item. Have Visual Studio create the files and then just copy and paste your existing code into them.

Now you should see your features in WSP view. Hit F2 to rename the the features and elements appropriately.