Archive for the ‘.NET Development’ Category

Consuming Filter Web Parts with a Web Part containing a User Control

August 15, 2009 Leave a comment

When wrapping an ASP.NET User Control in a web part, the user control is usually loaded in the CreateChildControls() method as shown below:

protected override void CreateChildControls()
  if (!_error)

       // Your code here...
       MyWebUserControl myControl = 
       myControl.DataProperty = SomeProcessing();
    catch (Exception ex)

Unfortunately this causes a problem when the embedded user control is to consume filter values coming from a web part connection because connections are evaluated after the CreateChildControls() method is executed. In the example above, when the SomeProcessing() method is executed no filter connections will have been created and therefore no filter values are available.

Therefore a mechanism is required to access the filter values later in the web part life cycle, perform filtering and update the user control with the filtered data.

The most obvious solution is to simply move the loading of the user control until after the connection has been created, for example in the OnPreRender() event handler. However this seems a little too ‘hacky’ to me. If anyone has a better suggestion please leave a comment below.


  1. Steven Van de Crean lists the order of execution for the ASP.NET web part in this blog post.

Preventing .aspx pages from being indexed by SharePoint

February 19, 2009 Leave a comment

One of the issues with having an ASP.NET web application hosted within MOSS 2007 is that pages with the extension .aspx are indexed by default.

Well, being SharePoint, it’s not quite that simple as revealed by the Search Visibilty page (Site Settings > Search Visibility):


In a nutshell, unless the lists or libraries within the site have broken the permission inheritance from the site, .aspx pages will be indexed.

This is bad. ASP.NET web application generally pages don’t contain anything of value for searching. Worse, if the page requires a value to be passed via a query parameter the search crawler will fail to parse the page and fill the crawl log with extraneous error reports.

Handily, as the screen shot above indicates, it is possible to turn off this behaviour. Unfortunately, this setting is made at the site level and therefore needs to be set for every site within the site collection.

A possible solution is to use code, as shown below:

web.ASPXPageIndexMode = WebASPXPageIndexMode.Never;
web.AllowAutomaticASPXPageIndexing = false;

This code snippet can be added to the site provisioning handler of a site definition, thus ensuring that all instances of the site will prevent indexing of .aspx pages.


Unfortunately, this doesn’t actually seem to work. The only method by which I can prevent the ASPX pages from being crawled is to create a Rule within the Search Settings for the Shared Service Provider to exclude all URLs ending in *.aspx.

If anyone can suggest why the settings made at the site level don’t seem to have any measurable effect, please leave a comment below…

Microsoft DevSta Winners announced

October 23, 2008 1 comment

Congratulations to the winners of the Microsoft DevSta 2008 competition: Michael Minutillo and Jarred Sargent.

Their prize-winning entry was a mobile device version of tag using GPS information to provide a map of the postions of players – an ingenious reworking of an old childhood game using the latest technologies from the Microsoft stable.

I’m lucky enough to work with both of them. 🙂