Archives for the 'ASP.NET' Category

Visual Studio 2008 COM Exception Error

This morning I tried to open a Web Application Project using Visual Studio 2008 and got the following error:
System.Runtime.InteropServices.COM Exception
Sounds bad, doesn’t it? But actually the solution is very simple. Just ensure that the value for IISURL in the .csproj (or .vbproj) file is valid.
I would like to thank Martin Kulov for this tip.

27 May 2008 | ASP.NET | No Comments

ASP.NET Page Life Cycle

This is a favourite interview question: “what are the sequence of events in the ASP.NET page life cycle?”
Short answer:

Init
Load
PreRender
Unload

Long answer:

PreInit
Init
InitComplete
PreLoad
Load
LoadComplete
PreRender
SaveStateComplete
Unload
Disposed

Short answer with explanation, i.e., what to do when:

Init – read or initialize control properties
Load – set properties in controls and establish database connections
PreRender – make final changes to the contents of the page or its […]

23 May 2008 | ASP.NET | No Comments

ASP.NET ViewState Misconception

A very common misconception amongst ASP.NET page developers is that ViewState must be enabled to persist values across postbacks.
This is not true. Try this: on an .aspx page, add a textbox and a button. Your code should be similar to the one as follows:


<body>
<form id=”form1″ runat=”server”>
<div>
[…]

13 May 2008 | ASP.NET | No Comments

Converting ASP.NET Web Applications from .NET Framework 1.1 to 2.0 and Above

When converting an ASP.NET web application from version 1.1 of the Microsoft .NET Framework to version 2.0 and above, the Visual Studio Conversion Wizard will convert your web application into what is termed a Web Site. In Framework 2.0 and above, ASP.NET apps come in two flavours: Web Site and Web Application Project [1]. The […]

16 April 2008 | ASP.NET | No Comments

Displaying the Column Headers of a GridView

The GridView of ASP.NET 2.0 will not display column headers if there is no data. The following is a workaround, assuming that you have added two BoundField columns to your GridView:
[C#]
DataTable dt = new DataTable();
dt.Columns.Add(”Description”);
dt.Columns.Add(”Amount”);
dt.Rows.Add(dt.NewRow());
GridView1.DataSource = dt;
GridView1.DataBind();
GridView1.Rows[0].Cells.Clear();
GridView1.Rows[0].Cells.Add(new TableCell());
GridView1.Rows[0].Cells[0].ColumnSpan
  = GridView1.Columns.Count;
The last two lines are not strictly necessary; I have included them so that the resulting HTML […]

22 November 2006 | ASP.NET | No Comments