Tuesday, February 21, 2006

Disclaimer

The views expressed on this weblog are mine and do not necessarily reflect the views of my employer.

All postings are provided "AS IS" with no warranties, and confer no rights.

Tuesday, February 14, 2006

UPGRADE ASP.NET 2.0: New Code Behind Model

In ASP.NET 1.x, the code-behind file was a class file that inherited the System.Web.UI.Page class, and the web page inherited the code-behind file. As a result, all the controls that appeared on the page were declared in the code-behind file so they would be available to both the code-behind file and page file.

Visual studio added a declaration to the code-behind file for each control. This declaration was placed in a region of the code-behind file which hidden. It was to hard to sync code-behind with page. Any control deletion, change in control name in page file might not affect the code region in code-behind file.

The new code-behind file not includes any hidden code region. Instead, the new model uses a partial class feature in VB 2005. Due to this control declarations are placed in separate file that's compiled together with the code-behind file to create final code-behind class file. All declarations created at compiled time by ASP.NET. So no mess-ups occurred.

Advantage is easier to keep the web page file in synchronization with the code-behind file.

Tuesday, February 07, 2006

VB.NET Bug: Toolbar Buttons Show No Text or Images in run time, although they appear correct at design time

Solution:
1. Expand the "Windows Form Designer generated code" section in the code view of the form.
2. Find out following statement in intializecomponents. (Replace Toolbar with actual toolbar control name)

ToolBar.Buttons.AddRange(...);

3. Cut above single line statement and Paste that statement of code at the end, after all of the properties of that ToolBar control have been set. [IMP: If Image list is used then paste above line after imagelist code block]

This will solve the problem.

[IMP: adding new controls or events, cause the IDE to regenerate the code, so the statement that causes the problem returns to its original location. Therefore, every time that you build and test the application, check the code file to make sure that above statement has been moved at the end]

Visitor Count: