Saturday, May 28, 2005

My first article published!

Read my first published article here at CodeProject. I developed a ControlInjector for applying a String.Format() pattern to server controls, mixing html literal content and private controls.

The benefit is similar to the benefit of String.Format(), where you separate the string itself, and the variables to insert.

Let me know what you think of it!
Monday, May 23, 2005

Server controls vs. User Controls

I ran across an interesting problem today, and I'm surprised that I have never read anything online or in ASP.NET books on the topic.

Basically I created a Wizard Control that will facilitate the common UI task of separating a long task into steps. The idea of a Wizard with Next/Previous buttons has been a foundation of windows applications since the beginning. Providing a similar interface for the web can help a lot.

The control provides a table that looks like this:












Header
Step 1 of 5
Content goes here...

so I have the control developed, all is well, the html looks all nice and neat like this:


<cc1:Wizard id="wizard1" runat="server" HeaderText="New User">
<cc1:WizardStep id="step1" runat="server" ValidationGroup="step1Group">
I am inside step 1!!!
</cc1:WizardStep>
</cc1:Wizard>



Now what if I wanted to encapsulate some of the controls in step1 into it's own user control? Sounds like it would tidy things up a bit. So I did this, and everything was okay. Until I wanted to make each ascx file in charge of validating and saving itself...

So I decide to instead, derive from FoundationWizardStep in the ascx code-behind. This way I could provide a couple public properties and method for validating and saving the form fields. This gives you an error though, because you cannot make a user control (one with an ascx file) derive from System.Web.UI.Control. Instead it must derive from System.Web.UI.UserControl. What's the difference, you ask? Well I suppose the it takes some extra steps in rendering to allow for rich designer support, but aside from that? Not much.

Now if I make FoundationWizardStep in turn derive from UserControl, I get even more weird behavior. I get a run-time exception in the html that the FoundationWizard doesn't have a child property of type FoundationWizardStep...

Now I have resolved the problem by eliminating the ascx control and making it a complete server control (class only). Anyone have ideas as to why this happened?
Thursday, May 19, 2005

Forza Motorsport

My new fix is Forza Motorsport for XBox. I am really getting into it. I particularly like how you can search for cars that match certain criteria; searching is a feature that is common to most applications (be it web, windows, whatever) but not so much in games... I'd like to see more of this.

Also, I REALLY like the fact that they licensed Porsche and Ferrari, these were missing from Gran Turismo 3 and it was disappointing (yes, I know that RUF's cars are really Porsches, but still)

I haven't yet played GT4 and was wondering how it stacks up against Forza.... I have a PS2, so I might pick it up if it's better than Forza.
Tuesday, May 17, 2005

VS 2005 Beta 2 has arrived!

I walked in my office today and opened the yellow envelope on the floor by the door to find:

  • Visual Studio 2005 Beta 2 - Team Suite CD
  • Visual Studio 2005 Beta 2 - Team Foundation Server
  • SQL Server 2005 Developer Edition - 365 day trial
Now I have to find the time to reformat my machine because there is no way I am installing anything heavy on it right now... it's running too slow.

Why in the world does VS2003 start moving like molasses after a couple months of use? When I add a new item to my solution I have to wait 3 full minutes before I regain control of the computer... how ghey.
Tuesday, May 03, 2005

ASP.NET 1.1 Master Pages

I was too impatient to wait for .NET 2.0's Master Pages, so I started to look at some of the (many) implementations for master pages in ASP.NET 1.1 ...


I ran across this article at CodeProject and I started to implement it in my new project. The basic idea behind it is to parse a child page (Context Page) and before Viewstate is even loaded, it does a Server.Execute to execute the desired master page, and the master page just loads its controls into the HttpContext (it makes sure not to render itself). The execution resumes at the Context page and the entire control collection of <form> is copied into a specifically named control and finishes execution!



The master page looks like this:


<html>
...
//header & navigation
<div id="masterContextContainer"> </div>

//footer
</html>




That's it! Mark the class with the [MasterPage()] attribute and it's ready to go!



The Context Page is just a normal aspx page that has the class marked as [ContextPage(masterPageAlias)] and it's done.



There are a number of different methods to accomplish this, but I found this one to be very nice because A) I can inherit my PageBase class from this MasterContextPage and start using it on existing web forms... B) it's very clever!


The only thing I found that is a little iffy is the Tracing. If you have both pages enabled it messes up, so make sure and set the Master Page to trace="false" so that you don't get any conflicts with control id's.
Sunday, May 01, 2005

Hear my email on .NET Rocks!

Carl Franklin from .NET Rocks! chose my email to read on the next show. Tune in and listen...

For my prize I got to pick from their section of "useless crap", and I chose the big-ass coffee mug... because I can always use more coffee! (I guess I am not dorky enough to wear a skin tight baseball shirt or truckers hat that says ".NET Rocks!" on it... )

If you aren't a regular listener, you should really try it out, most of the time you'll learn a thing or two new, and it's sometimes pretty funny. My favorite shows were with Scott Hanselman & Rory Blyth and Bill Vaughn & Rocky Lohtka. Here's a hilarious quote from the show:

"I'm done with objects."

- Rocky Lohtka on .NET Rocks at Dev Connections 2005

Remortgage - Renegade motorhomes - Arizona Pools - Credit Card Consolidation