Månad: september 2009

Usefull stuff unsorted

I have a very bad memory, this blogg helps med remember som tips and tricks that will make my life as a system developer easier. Today I have this tips:

XML Documentation Comments

This was erlier integrated in Visual Studio now it´s a hidden and for many new developers maby unknown. If you compile with the switch /doc you will have nice documentation of all you comments added with ///

Like this for example:

/// <summary> /// This class performs an important function. /// </summary>
public class MyClass{}

Read more about this feature: http://msdn.microsoft.com/en-us/library/b2s063f7(VS.80).aspx

C# Preprocessor Directives

A nice feature, today I want to mark a class with the preprocessor directive #warning because I want this to be there until we investigated if the class should be deleted or not. Add a //TODO is not enough a warning is stronger and forces us to dont miss this before deployment.

Read more about this here: http://msdn.microsoft.com/en-us/library/ed8yd1ha(VS.71).aspx

Problem with gridview or any other asp control events

In my current project I had problem with the execution orders on a ASP.NET page, I use a databound gridview, that databinds in PageLoad. But when I then hit the select row and that event fires I dont want to databind on PageLoad of course, but how to I do that? The Execution order is first PageLoad then SelectedRowChange on the gridview. This is my solution:

if (Request.Form["__EVENTTARGET"] != GridView1.UniqueID)

    GridView1.DataSource = GetTransactionData(

"", false);

Note that I can do a check of what triggered the page reoload, and then skip the databinding if the gridview populated this, because i know that the row index change event on the gridview will take care of the databinding. Time for lunch now 🙂

Grouping partial classes in Solution Explorer

I found a great tool today that I could recomend, I was looking for a tool to easily group partial classes without manually edit the project file. Why do I want this feature then? Well I like organizing things and since the partial classes feature is such a good thing doing just that I like it.

But the bad thing is that the nice group layout of partial classes that Visual Studio it self uses when it separates for example a Winform in three files like form1.cs, form1.Designer.cs and form1.resx is something you dont can do in a simple way.

But thanks to Jarek Kardas this problem is solved with his nice tool VsCommands, take a look at it and download it from here