Thursday, April 06, 2006
« Something that just bugs me. | Main | .NET 2.0 Use IIS instead of the Developm... »

So I'm into my second night of VS2005, and .NET 2.0. I'm working on a super secret project with a friend of mine. Hopefully we'll have something fun to show in a month or so. Anyways, I decided why not use .NET 2.0?

So I could just code it in 2.0, the way that I would in 1.1, but what would that accomplish? So I've got a really good book, and I'm teaching myself as I go.

One of the first things in .NET 2.0 that sounded really cool (actually it is pretty cool) is Master Pages. A Master Page is basically a file that you define that you can have other pages visually inherit from. What this means is the 10 pages of our site that all have the same layout inherit from one master page. If we want to move the ads, or switch the navigation, it's one file to edit.

Inside a Master Page, you can define areas that are for content. You then add Content Pages to VS 2005. So here comes the issue I ran into, and it took a while to figure out:

   Issue:
   My Master Page was defined as MasterPage.master. I added a bunch of HTML, added a content
   page called default.aspx that was linked to the Master Page. The default content page had the
   word test in it printed from the codebehind. Every time I debugged into this codebehind call,
   I noticed the Page_Load event was being called twice, and it was never a postback. I messed
   around with AutoEventWireUp in both the Master Page and the Content Page, to no avail.

   Solution:
   
I started removing HTML. When I went back to a blank page, w/ no additional HTML, the page
   events behaved correctly. I finally found this was causing the problem (my bad HTML).

      <asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
      
</asp:contentplaceholder>

      <div style="BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; BORDER-LEFT: #000000 1px solid; BORDER-BOTTOM: #000000 1px solid"><img alt="#" src="#"/></div>

   
Removing the div tags w/ the inline styles stopped the events from firiing twice. Sure maybe
   it's bad to have inline styles applied to a div, but man I wouldn't expect that type of behaviour.

   I'm going to tackle THEMES and SKINS next, so I'm sure I'll see why soon.