December 2009 Entries
Every so often I find it necessary to force a SharePoint web part page into edit or design mode using query string parameters. Originally posted on one of our internal development blogs, I decided to share this because it does come in handy from time to time. SharePoint Query String Parameters Query String Parameter Values DisplayMode ...
One of the thing that has always bugged me about the SharePoint 2007 Outlook Web Access (OWA) web parts ever since I saw them was that that some of the web parts lack basic functionality and thus are inconsistent in their functionality. The purpose of this post is to shed some light on what these web parts do or cannot do and give users an understanding of how to get around the lack of functionality. Before I continue, I should remind readers that these OWA web parts are intended to be used in a My Site and that users of...
This control produces a meta description element for use in the head element of a page, like this: <meta name="Description"
content="Solien Technology is a Microsoft Gold Certified Partner
and Microsoft Managed Partner in Southern California." />
The .net framework’s System.Web.UI.HtmlControls.HtmlMeta control renders as a meta tag, and by using Microsoft.SharePoint.WebControls.FormComponent as our base class we gain access to the current SharePoint item.
namespace Solien.SharePoint
{
/// <summary>
/// Adds a meta description tag based...
Here’s a control that shows the first non-blank SharePoint field. I created it for Solien’s web site when I added the PageTitle field. By using this control, if content authors leave the PageTitle field blank the contents of the Title field are shown instead. By inheriting from Microsoft.SharePoint.WebControls.FormComponent we gain access to the Item property. using System.ComponentModel; using System.Web.UI.WebControls; namespace Solien.SharePoint { ...
Here’s how to add a new field to an existing page layout in Microsoft Office SharePoint Server 2007. Our current page layout uses the Title field both for the HTML title element shown browser’s title bar and for the header shown in the content. We want to separate these so that the HTML title can be different. We’ll be modifying the SolienInnerPage.aspx and SolienInnerPageNoLeftNav.aspx page layouts. Here’s an outline of the work we’ll need to do: Find the associated content type for the page layout Add a new site column...
Today a web service call was failing in a way I'd never seen before: System.Xml.XmlException: Unexpected end of file has occurred. The following elements are not closed: faultstring, soap:Fault, soap:Body, soap:Envelope. Line 905, position 45.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
at System.Xml.XmlTextReaderImpl.Throw(Int32 pos, String res, String arg)
at System.Xml.XmlTextReaderImpl.ThrowUnclosedElements()
at System.Xml.XmlTextReaderImpl.ParseElementContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlTextReader.Read()
at System.Xml.XmlReader.ReadString()
at System.Xml.XmlTextReader.ReadString()
at System.Xml.XmlReader.ReadElementString()
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadSoapException(XmlReader reader)
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
System.InvalidOperationException: Response is not well-formed XML.
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at [...]
I fired up Fiddler2 to see what was going on.
This is a local web service, with...
In an application with lots of complex dependencies, writing unit tests that actually test a single unit of code is challenging. A customer has a large application where most of the "unit" tests are actually integration tests that rely on known test data in the database. For new development in this application, I've been moving toward true unit tests where possible. Using mock objects helps. Instead of the external dependencies for the system under test relying on the database, I mock the dependencies with RhinoMocks. Configuring the test data in the mocks is still painful, though, since each...
Sometimes it's useful to have an SMTP service that doesn't actually send email. That's easy to do using Tcl. Here's the script to use: package require smtpd
catch [wm withdraw .]
catch [console show]
proc deliver {sender recipients data} {
set mail "To: $recipients\nFrom: $sender\nDate: [clock format [clock seconds]]"
append mail "\n" [join $data "\n"]
puts $mail
}
::smtpd::configure -deliver ::deliver
::smtpd::start
Here's what sending email from the command line looks like:
C:\>telnet localhost 25...
For a recent prototype, we needed to add required-field validators to a bunch of fields in asp.net DetailsView controls. We had to convert each BoundField to a TemplateField and add a RequiredFieldValidator. In other words, we needed to transform <asp:BoundField DataField="Country" HeaderText="Country" HeaderStyle-CssClass="importantHeader" /> to <asp:TemplateField HeaderText="Country" HeaderStyle-CssClass="importantHeader"> <ItemTemplate> <%# Eval("Country") %></ItemTemplate> <EditItemTemplate> <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Country") %>'></asp:TextBox><asp:RequiredFieldValidator runat="server" Display="Dynamic" ControlToValidate="TextBox3" Text="Required" /></EditItemTemplate> ...
Now that we’ve got an asp.net DetailsView control with fields from a SubSonic ObjectDataSource and we’ve set the header text, it’s time to work on the code-behind code needed to update the object. The DetailsView template has the following fields: <asp:BoundField DataField="DirectMarketing" HeaderText="Direct Marketing" SortExpression="DirectMarketing" /> <asp:BoundField DataField="AffiliateMarketing" HeaderText="Affiliate Marketing" SortExpression="AffiliateMarketing" /> [... and lots of other fields] We’ll use Visual Studio 2008’s find and replace to generate the update code. Find what:...
Regular expressions in Visual Studio’s find and replace can save a lot of time. For a recent project, we used a DetailsView bound to an ObjectDataSource generated by SubSonic. The bound fields were almost, but not quite, what we needed. They were quickly updated with some regular expression magic. The DetailsView has camel-cased text for the field names and the header text. <Fields> <asp:BoundField DataField="CustomerBase" HeaderText="CustomerBase" SortExpression="CustomerBase" /> ...
The DetailsView control helps accelerate web application development. For a recent ASP.NET project, we used it in conjunction with SubSonic to create a rapid prototype. The data objects generated by SubSonic make it easy to create and configure a DetailsView control. First, create the necessary controller if needed. Here's the partial class I created for the Share table: using System.ComponentModel; namespace CustomerProject.Data { public partial class ShareController { [DataObjectMethod(DataObjectMethodType.Select,...