This article lists the aliasses you can use in visual studio when searching with a regular expression.

http://msdn.microsoft.com/en-us/library/2k3te2cs(VS.80,ide).aspx

For example  if you want to find all guids in your solution

  • CTRL-SHFT-F (find in files)
  • Entire Solution
  • check the Use Regular Expressions box
  • type in the find box :h^8-:h^4-:h^4-:h^4-:h^12
  • go

 


Article about how to add a "Get PublicKeyToken" menu item in Visual Studio

http://blogs.msdn.com/b/miah/archive/2008/02/19/visual-studio-tip-get-public-key-token-for-a-stong-named-assembly.aspx

Basic steps:

  • Tools --> External tools..
  • Title: Get PublicKeyToken
  • Command: C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\SN.exe
  • Arguments: -T $(TargetPath)
  • Check Options: Use Output window

Make sure you build your project before using this new tool.
I love this, and think it should be added on every developers machine.


WSPBuilder extensions for Visual Studio are great. If you use WSPBuilder to create webparts however, you might have run into the fact that by default Visual Studio does not allow you add Web User Controls to a WSPBuilder project.

At the project I'm currently working on, we use WSPBuilder and usercontrols for the visual part of the webparts we create. To make life a bit easier we altered the projectfile of our webparts project.

If you change:

<ProjectTypeGuids>fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>

To

<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>

Visual Studio wil think it is now a WebApplication, and will allow you to add usercontrols by using Add --> New Item on your WSPBuilder project.


Thanks to Jeffrey Tummers for retrieving the id's


<SiteFeatures>
  <!-- Content Type Syndication Hub -->
  <Feature ID="9a447926-5937-44cb-857a-d3829301c73b" />
  <!-- Document ID Service -->
  <Feature ID="b50e3104-6812-424f-a011-cc90e6327318" />
  <!-- Document Sets -->
  <Feature ID="3bae86a2-776d-499d-9db8-fa4cdc7884f8" />
  <!-- SharePoint Server Enterprise Site Collection features -->
  <Feature ID="8581a8a7-cf16-4770-ac54-260265ddb0b2" />
  <!-- SharePoint Server Standard Site Collection features -->
  <Feature ID="b21b090c-c796-4b0f-ac0f-7ef1659c20ae" />
  <!-- Workflows -->
  <Feature ID="0af5989a-3aea-4519-8ab0-85d91abe39ff" />
</SiteFeatures>
<WebFeatures>
  <!-- Metadata Navigation and Filtering -->
  <Feature ID="7201d6a4-a5d3-49a1-8c19-19c4bac6e668" />
  <!--SharePoint Server Enterprise Site features-->
  <Feature ID="0806d127-06e6-447a-980e-2e90b03101b8" />
  <!--SharePoint Server Standard Site features-->
  <Feature ID="99fe402e-89a0-45aa-9163-85342e865dc8" />
</WebFeatures>


A really nice (and funny) article why you should not do this, by Tyler Holmes.

http://blog.tylerholmes.com/2008/10/don-set-your-sharepoint-app-to-full.html

I came across this article because we had an assembly containing a feature reciever that would cause an error when executed.
Assemblies containing feature recievers should always go in the GAC (by design), but we where creating a custom policy.

So, I agree with Tyler that custum policies are still preferable, but when you have a dll that contains a feature reciever, you should just put it in the GAC.


.Net University

Published 10/9/2009 by Jeroen Derde in asp.net | LINQ | MVC | QNH

 

Free download of Powerpoint slides, demos, video's and example code of around 40 .net courses.

http://dotnet-u.com/Courses.aspx

Enjoy.

 


LINQtoSQL cheatsheet

Published 8/21/2009 by Jeroen Derde in asp.net | LINQ | MVC | SQL

 

 

 

 

 

DamienG, just posted a LINQ to SQL cheatsheet for C# and VB.net.

Download it at: http://damieng.com/blog/2009/08/12/linq-to-sql-cheat-sheet

 


REST for asp.net MVC SDK

Published 8/18/2009 by Jeroen Derde in asp.net | MVC | QNH | REST

 

 

 

 

 

 

Phil Haack just posted about REST and ASP.NET MVC.
He explains why the WCF team at Microsoft has put together an SDK and samples for building REST services using ASP.NET MVC.

The post can be found at: http://haacked.com/archive/2009/08/17/rest-for-mvc.aspx

I'll be giving this SDK a go, and keep you updated on my findings.

You might also want to take a look at this article about building a WCF REST client: http://damianm.com/tech/building-a-rest-client-with-wcf/

 


WittyTwitter TwitterLib

Published 7/14/2009 by Jeroen Derde in asp.net | twitter | QNH

 

Found this .Net wrapper for the Twitter API called TwitterLib. It's part of WittyTwitter, but can also be used on it's own.

Code can be found here. http://wittytwitter.googlecode.com/svn/trunk/Witty/TwitterLib/
Nice if you are planning on building a twitter enabled app.

 

 

 


Today I was experiencing a problem in the MVC application I am currently developing.

First some information:

Model: ContactDataModel
ContactDataModel implements interface IContactData. This is because the related typedview Step1 contains a partialView that inherits IContactData.
this way we can reuse the partial view simply by having each model, that needs to use the partialview, implement this interface.

 

Interface IContactData


public interface IContactData
{
    ContactData Contact { get; set; }
}

 

Object ContactData


public class ContactData
{
    [Required]
    [StringLength(200)]
    public string Voornaam { get; set; }
}

 

View: Step1
This view inherits from ContactDataModel


...
<h2>ContactGegevens</h2>  
<% Html.RenderPartial("ContactDataUserControl"); %>
...

 

Partial View: ContactDataUserControl
This view inherits from IContactData


<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<QNH.Interfaces.IContactData>" %>
<%= Html.ValidationSummary("Create was unsuccessful. Please correct the errors and try again.") %>
<% using (Html.BeginForm()) {%>
<fieldset>
    <legend>Fields</legend>
    <p>
        <label for="Contact.Voornaam">
            Voornaam:</label>
        <%= Html.TextBox("Contact.Voornaam")%>
        <%= Html.ValidationMessage("Contact.Voornaam", "*")%>
    </p>
.........more fields....form closed

 

Controller: MyController


[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Step1( ContactDataModel contact )
{
    ....
}

 

The "POST" method "Step1" on MyController was recieving an empty ContactDataModel object. If I changed the the Step1 method to recieve the FormCollection instead of the Model object then my values would be present. After this I thought: what object is responsible for mapping the formvalues in my view to my model object. The answer is: the ComplexModelBinder.

The main thing to remember when using the ComplexModelBinder is the naming convention of your controls in the form. Because it uses reflection the ComplexModelBinder is expecting the Class Name + “.“ to be appended to the property name. If you are using the ComplexModelBinder and not prefixing the Class Name to the name of the Property, you will just get null values for your properties.

This means that in my partial view were I was using Contact.Voornaam I needed to use ContactData.Voornaam.This also means that I needed to change the name of the property in my interface to ContactData, because else it would not be recognised.

New Interface: IContactData:


public interface IContactData
{
    ContactData ContactData { get; set; }
}

New Partial View: ContactDataUserControl
This view inherits from IContactData


<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<QNH.Interfaces.IContactData>" %>
<%= Html.ValidationSummary("Create was unsuccessful. Please correct the errors and try again.") %>
<% using (Html.BeginForm()) {%>
<fieldset>
    <legend>Fields</legend>
    <p>
        <label for="ContactData.Voornaam">
            Voornaam:</label>
        <%= Html.TextBox("ContactData.Voornaam")%>
        <%= Html.ValidationMessage("ContactData.Voornaam", "*")%>
    </p>
.........more fields...form closed
 

 

I really hope this helps out someone else. Happy Coding.

 


Jeroen Derde's Blog

My Software Engineering Universe