Tuesday, October 6, 2009

LoadControl problem in ASP.Net

Today I met a problem and it made me angry enough to make some dumb checks and found an interesting thing conecrning the runtime control loading. I was trying to load controls using the LoadControl method in this way (using this overload of the method): LoadControl(type, object[]). This seemed ok - the control is being instanciated but when I was trying to access a property of it - found that all the inner controls were not loaded and I was getting NullReferenceException.
And here was the solution - seems that the LoadControl(string) overload works much more better and using this overload you can get the required control with all its properties initialized.
Good luck.

Saturday, October 3, 2009

Get all the best from VS.Net

After moving to a new company I have found that all the developers here have installed some addons on the VisualStudio.Net 2008 which make it load slower and found that they only use it for some features like outline.
This make me to write this post about the best and also most important feature in VS.Net, which is not expsed by default (only in VS.Net 2003). This feature is just Class View Synchronization with the class/struct, your cursor is in. So here how you can enable it.
1. In the toolbar area right click and select Customize... from the opened context menu.
2. Go to the Toolbars tab, and enable the ContextMenus item in the list. This will make a new toolbar appear in the toolbars.
3. Go to the Commands tab of the Customize window, and select the View item in the Categories list.
4. Now navigate to the Synchronize Class View item in the Commands part of the same tab. Drag it to the new added toolbars Editor Context Menus item (a menu will appear), and drop somewhere in the Code Window submenu.
Here it is. Now you can use that amazing feature from your context menu.