Wednesday, November 28, 2007

UserControls based on abstract classes in designer

I really hate the fact, that VS doesn't allow to display design of user controls (of forms) based on abstract classes.
Here i found solution to the problem - basically "fooling" the designer with substitute artificial instance. It's just a little messy (especially when you have abstract classes in different assemblies), but it seems to work. Mentioned example is done for forms, but works equally well with user controls.

Tuesday, November 27, 2007

Extending indexer on collection in C#

I was looking for a way to implement alternative way to access members of List (or any other collection) through index. By default i could use only:

myCol[0].Value

What i'd like to use is:

myCol[strKey].Value

The way to implement it is through property (code-fragment only):

public MyColItem this[string strKey]
{
get { return #code to get the item#; }
set { #your code#; }
}

ASP.Net 2.0 Precompilation

Since i never remeber the command-line for precompilation, i found AspNetCompiler very handy...