Posted on Feb 28, 2008

Check out my Pownce Feed

I’ve place a badge on my home page that displays my two latest Pownce posts, and dedicated an entire page Pownce Feeds that lists my 30 most recent Pownce posts.  Things that ramble off my brain that don’t deserve a full blog post will get Pownced.

Posted on Feb 28, 2008

Format DateTime to Short Date when Binding in ASP.Net

Here’s how to format a DateTime value to a Short Date when Binding in ASP.Net:

<%# Eval(“StartDate”, “{0:d}”) %>

Posted on Feb 28, 2008

How to style a table for Sharepoint

The Sharepoint GridView is not as fancy as the ASP.Net Listview, therefore it’s better to use an ASP.Net Listview to display a data table and style the table with the Sharepoint style classes.  Here are my notes on how to style a data table for Sharepoint:

 

Table

Table Style: border-style:None;width:100%;border-collapse:collapse;

Table Class: ms-listviewtable

Header Row Class: ms-viewheadertr

Header TH: ms-vh2-nofilter ms-vh2-gridview

Item TD: ms-vb2

 

Data Paging

The TD surrounding the DataPager: ms-listheaderlabel

Data Pager:

<asp:DataPager ID="DataPager1" runat="server" PageSize="10">

<Fields>

<asp:NextPreviousPagerField ButtonType="Image" ShowFirstPageButton="True" ShowNextPageButton="False" ShowPreviousPageButton="False" FirstPageImageUrl="/_layouts/1033/images/prev.gif" LastPageImageUrl="/_layouts/1033/images/prev.gif" NextPageImageUrl="/_layouts/1033/images/prev.gif" PreviousPageImageUrl="/_layouts/1033/images/prev.gif" />

<asp:NumericPagerField />

<asp:NextPreviousPagerField ButtonType="Image" ShowLastPageButton="True" ShowNextPageButton="False" ShowPreviousPageButton="False" FirstPageImageUrl="/_layouts/1033/images/next.gif" LastPageImageUrl="/_layouts/1033/images/next.gif" NextPageImageUrl="/_layouts/1033/images/next.gif" PreviousPageImageUrl="/_layouts/1033/images/next.gif" />

</Fields>

</asp:DataPager>

Posted on Feb 28, 2008

How To Dynamically Set a LinqDataSource to filter the results based on user input

Here’s an example of how to dynamically set the where property on a LinqDataSource to filter data based on user input from a textbox.  In this case we have a Linq entity called ContractsEntity that has a table called ContractHeaders.  Not shown in this example is the listview (in the Ajax UpdatePanel) that is bound to the LinqDataSource.  The listview will show all contracts by default, but I want the user to be able to enter text to filter the results.  The user enters data in the textbox and clicks on the Search button.  This causes the UpdatePanel to send an Ajax request which fires off the SearchContractNumButton_Click event.  In the event I set the LinqDataSource Where property to do the filtering.

The ASP.Net source looks like this:

<form id=”form1″ runat=”server”>

<div>

<asp:LinqDataSource ID=”ContractHeadersLinqDataSource” runat=”server”

ContextTypeName=”ContractsEntity” TableName=”ContractHeaders”>

</asp:LinqDataSource>

<asp:ScriptManager ID=”ScriptManager1″ runat=”server”>

</asp:ScriptManager>

<asp:UpdatePanel ID=”UpdatePanel1″ runat=”server”>

<ContentTemplate>

<div>

<p>Enter a contract to search for:</p>

<p>Contract # <asp:TextBox ID=”SearchContractNumTextBox” runat=”server”></asp:TextBox>

<asp:Button ID=”SearchContractNumButton” runat=”server”

onclick=”SearchContractNumButton_Click” Text=”Search” />

</p>

</div>

</ContentTemplate>

</asp:UpdatePanel>

</div>

</form>

In the code behind the Button’s OnClick event looks like this:

protected void SearchContractNumButton_Click(object sender, EventArgs e)

{

ContractHeadersLinqDataSource.Where = “ContractNum.Contains(\”" + SearchContractNumTextBox.Text + “\”)”;

}

After further testing I have determined that this is not the best way of doing things, it stops working with paging.  Once I have figured out a better way of doing this I’ll post it.

A better way of doing this requires absolutely no code!  Configure your LinqDataSource in design view and click Next in the Choose a Context Object window.  Click on the Where button to configure the Where.  Make sure Automatically generate the Where Expression… checkbox is not checked.  In the Where Expression text area enter

ContractNum.Contains(@ContractNum)

Click on the Add Parameter button to add the Parameter.  In Parameter Source choose Control.  In ControlID choose SearchContractNumTextBox.  Click on the Show advanced properties link to show advanced properties.  Change ConvertEmptyStringToNull to False (Missing this step will cause an error on the page).  Change Name to ContractNum.  See the screenshot below.  Click OK and Finish.  Your filtering should be all set to go!

LinqDataSource Filter On User Input

Posted on Feb 27, 2008

Installing ASP.NET 2.0 AJAX Extensions 1.0 in Windows SharePoint Services Version 3.0

This is a great walk through on how to install ASP.Net 2.0 Ajax Extensions in Sharepoint so you can write and use Ajax-enable applications within sharepoint.  Use this in conjunction with Microsoft .Net 3.5 applications and you can get some nice apps written quickly using LinqDataSource, Listviews, and ASP.Net Ajax.  A tutorial is coming soon.

 

There is a note in the installer:

Note that the procedure described below applies to .NET Framework 2.0. If you are using .NET Framework 3.5, change the version number in each of the XML snippets from Version=1.0.61025.0 to Version=3.5.0.0.

 

I followed the directions and replaced all 1.0.61025 to 3.5.0.0 and had no problem with WSS 3.0 SP1.

 

Installing ASP.NET 2.0 AJAX Extensions 1.0 in Windows SharePoint Services Version 3.0

Posted on Feb 27, 2008

Where are the Sharepoint Logs?

When debugging an application I’m writing in Sharepoint I’m always trying to find the Sharepoint logs, so I posted this for me to remember.  The logs are located here: 

C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\LOGS

Posted on Feb 27, 2008

How to install a Sharepoint application template

  1. Remote Desktop into WebServer1.
  2. Download the .exe file from the internet and save it to c:\Documents and Settings\[USERNAME]\My Documents\Application Templates.
  3. Create a new folder in the Application Templates folder with the name of the new application template to be installed (i.e. Knowledge Base).
  4. Run the .exe file, which is a self-extracting zip file and choose the newly created folder (Knowledge Base) to extract the files to.
  5. Open up a command prompt and change into the folder (c:\Documents and Settings\[USERNAME]\My Documents\Application Templates\Knowledge Base)
  6. Enter the following command:  "c:\program files\common files\Microsoft Shared\Web Server Extensions\12\bin\stsadm" -o addsolution -filenamename APPLICATIONTEMPLATENAME.wsp
  7. You should see "Operation completed successfully"
  8. Enter the following command:  "c:\program files\common files\Microsoft Shared\Web Server Extensions\12\bin\stsadm" -o deploysolution -name APPLICATIONTEMPLATENAME.wsp -allowgacdeployment -immediate
  9. You should see "Timer job successfully created."

Posted on Feb 27, 2008

Individual Windows Live Installers

If you’re having trouble installing any Windows Live applications using the Windows Live Installer, you can browse to this Windows Live SkyDrive folder and download the individual installers themselves.  You won’t get all of the functionality (There is no shortcut to Windows Live Writer for me, but I can get to it through Internet Explorer).

Posted on Feb 27, 2008

Using ASP.Net 3.5 controls in Windows Sharepoint Services

Make sure you have the Microsoft .Net 3.5 Framework installed on your servers, and place the following in each Web Application’s web.config file under configuration/system.web/pages:

<controls>

<add tagPrefix=”asp” namespace=”System.Web.UI.WebControls” assembly=”System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35″ />

</controls>

The web.config files are generally found here:  C:\Inetpub\wwwroot\wss\VirtualDirectories\[PORT NUMBER].  If the controls tag is already present in the pages tag, then put the <add tagPrefix… tag in the existing controls tag.

Posted on Feb 21, 2008

Coda-Slider 1.1.1

The Coda Slider is an Ajax tabs that transitions from tab to tab in a really neat manner.  All you have to do is wrap your tab pages in some divs with specific classes assigned to them and you’re good to go.  The required javascript is downloadable, and requires jQuery.

Coda-Slider 1.1.1