Simple clean coding example


Here is a site which shows the relative space distance to the moon and mars from earth. While the content is interesting (it’s use I am unsure), I am more impressed by the small script used to run this webpage.

Have a look:

http://distancetomars.com/

Completely remove a user from a site collection – SharePoint 2010


The easiest way is to access the user information list via the url:

http://site_collection/_layouts/people.aspx?MembershipGroupId=0

Here if you select a user you can click “Remove from site collection”

Exchange 2010 Dynamic Distrubution Groups – Filter by any AD Property


If you miss the ability to filter dynamic distribution groups on more than custom attributes from Exchange 2007 then don’t fret! This is still possible via powershell:

 

new-DynamicDistributionGroup -Name ‘Group1′ -RecipientFilter {((Office -eq ‘City’ -or Office –eq ‘Richmond’))} -RecipientContainer “domain.com” -Alias ‘Group 1′

 

Check out RecipientFilter on MSDN for more info on the properties you can filter on.

SharePoint 2010 Maintenance Page


The SharePoint Maintenance page is used to close and delete web parts from a page without actually being on the page. This is useful for when you screw up a web part bad enough that it crashes the whole page.

 

You can access via the “All site content” link or via the url directly like:

 

http://server/_layouts/spcontnt.aspx?&url=/SitePages/home.aspx

 

or for sub-sites:

 

http://server/_layouts/spcontnt.aspx?&url=Marketing/SitePages/home.aspx

C# Export ASP.Net GridView to Excel or PDF Dynamic Data


Often a business requirement to share information in these formats.

Firstly Excel export:

 

You can change table.DisplayName to what you want your file to be named and  remove the following if you are not using a Dynamic Data site:

 

For PDF export:

I used iTextSharp for this with the following usings:

Again if you are not using a Dynamic Data site, you may not need to replace the <a> tags but iTextSharp seems to dislike them and will throw errors.

Notes:

  • You may have to set EnableEventValidation=”false” on your ASPX page. This was fine for me internally but on something public facing you may want to look into work arounds.
  • You may need to register your controls for post-back like:

 

 

Code Run is proudly powered by WordPress.
Theme "The Fundamentals of Graphic Design" by Arjuna
Icons by FamFamFam