The Coding Humanist

Archives: 4/2006

I've been watching the asp.net forums on the asp.net (www.asp.net) site lately. Some good questions. A number of not so good questions. Here was a good one.

Somebody asked how to create a custom server control that does not automatically render a span tag surrounding the contents. Good question. The guy who answered gave two choices, both good.

First, inherit from Control, not WebControl. That's the easiest.
Second, override the render, call the render on all the individual controls, and don't call base.Render().

The first is much easier, unless you already have to do some of your own rendering anyway. If you do, just don't call base.Render().

So, just as an example, here is the difference between rendering inheriting from Control and WebControl, respectively (both have three child controls, a button, a label, and a text box).


<input type="submit" name="myButton" value="Button" id="myButton" /><span id="myLabel">Label</span><input name="myTextBox" type="text" value="TextBox" id="myTextBox" />

or:
<span id="FancyWebControl1"><input type="submit" name="myButton" value="Button" id="myButton" /><span id="myLabel">Label</span><input name="myTextBox" type="text" value="TextBox" id="myTextBox" /></span>

As you can see the differences are all in the outer span, which includes the span tag itself and an id tag for the id given in the aspx page.

Here's the page declaration, for your reference:
        <Custom:FancyControl ID="FancyControl1" runat="server"></Custom:FancyControl>
        <Custom:FancyWebControl ID="FancyWebControl1" runat="server" />

The first control, which descends from System.Web.UI.Control, only has its child controls rendered, so the id "FancyControl1" never gets rendered into the output.

The Coding Humanist, Finally with a Longer Title - MCTS

-- Filed Under: General
Comments: (0)
Well, it is about time. I got two certifications under the old 1.1 cert system, just enough to keep me an MCP. Now, finally with two from the new system, I am now an MCTS. Woohoo! I passed the Web development test yesterday evening. Rock on...

Skinning Custom Controls Issue

-- Filed Under: ASP.NET
Comments: (0)
I just ran into this issue. Took me a few minutes to figure out. And there just isn't enough on google for this particular compile time error, so I thought I would help (searching with "The control type" and "cannot be themed" only gets nine hits presently).

If you ever create a custom control and try to theme it, you might get the following exception:

The control type 'YourNamespace.YourControlName' cannot be themed.


Add the following attribute to your class:

[Themeable(true)]

Problem solved.

The Development Abstraction Layer

-- Filed Under: Development
Comments: (0)
Interesting article by Joel.

I think this article is basically saying the following: 1) every distraction that programmers have that they do not need to have needs to go away, 2) they should be catered to, and 3) everybody else in the organization exists for the purpose of supporting the programmers, either by doing 1 and two above or by being the machine to sell and support what the programmers make.

I love it. Love it, love it, love it. After all, I am a programmer! In some kinds of companies there is some validity here. Let's say you have a company that makes is money on selling software. In this case those things really are true. If you have a company, however, where IT is just a small part, a sort of infrastructure, then not everything there applies.

The unfortunate thing about these ideas, especially number 2, is that it is easy to get the idea that programmers are just a bunch of babies. Some are, of course, but I don't think that is the case usually. This is assuming, of course, that we're talking about good programmers. Bad programmers may or may not be babies, but they should be fired and replaced anyway. Anyway, I digress. I don't think it's lack of maturity or a sense of entitlement, but that there is a programmer culture that is radically different from that found in other groups such as sales, accounting, support, management, etc. ALL of these groups have different cultures, and development's culture is radically different from the others. Take, for example, the idea of giving developers their own offices. This actually makes a great deal of sense for programmers. Distractions are very costly to development. It's just disastrous when a developer gets "in the zone" and is then distracted by some pesky manager about this or that project. Granted, developers have to be distracted sometimes (yes, it is ok to talk to developers), but as a general rule they should not be. When developers are "in the zone" they get a lot more and better work done. That's what you want, right?

And its not that programmers should be catered to and no one else. Every group needs to have their needs met and be satisfied at their job, because you'll get a higher retention rate and satisfaction level, which will greatly affect the effectiveness of your company. And one of the important points that can be drawn from Joel's article is that when any group is cental to the company, it SHOULD be catered to, whether that's sales, support, or development. For ISV's this often, if not always, is development.

Make a truly good development environment and you'd be surprised what you can get out of your programmers.

Victory In MPower Football

-- Filed Under: General
Comments: (0)
Today I overthrew my rival at MPower Football (a game involving the kicking of a small squishy orange ball into the mouth of a cup about 10 feet away -- an incredibly difficult sport. It's really great for a break when you're tired of dealing with untyped datasets and other things that are annoying to deal with.) to regain my championship. David fell, defeated and weeping, having been beaten 3 out of 5 shots to 0 out of 5. Next James, my former mentor at the game tried to challenge, but fell defeated 2 out of 5 to 1 out of 5.

Victory!
So I found out that the copy source as html visual studio addin has been ported to 2005. You can get it here. So which one is better? How about some code samples...

Using the VS addin:

   18         public void ShowSomething()

   19         {

   20             MessageBox.Show("I am a code sample. Hear me roar!");

   21         }


Using the online code formatter:


   1:          public void ShowSomething()
   2:          {
   3:              MessageBox.Show("I am a code sample. Hear me roar!");
   4:          }


So, the result? I do like the colored lines affect you can get with the online code formatter. It can also do t-sql. Don't know if the other one can. However, the addin has some features that the other doesn't, like removing indentation and line breaks (not that I see myself using them, but whatever...). It also mimics the coloring you see in Visual Studio, which is nice. So, decide for yourself which one you like most.

Online Code Formatter

-- Filed Under: General, Tech Review
Comments: (0)
Want to show code in your blog? Here is an online utility for doing that. There was a visual studio add-in for 2003 that did this. I wonder if it works in 2005...

Anyway, this one works.

NDDNUG Meeting Last Night

-- Filed Under: General
Comments: (0)
Last night was the latest North Dallas .NET User Group meeting. As always (or almost always), it was interesting. Of course, free food. That's nice. The presentation was on open source and freeware tools that are useful for .NET developers. Only one or two were new to me, but I enjoyed the chat anyway. And there's a number of guys I only see at the meetings, so it was nice to see them as well. If you live in the Dallas area, I highly recommend visiting sometime.

I Now Support Multiple Blogging Platforms

-- Filed Under: General
Comments: (0)
One is about to be disabled. There is the old blog at blogger. There is my biblical studies blog at www.christonomy.com. That one is running on Community Server 2.0. This one is running on the latest version of DasBlog. So, which one will I like best? We'll see.

The main reason why I chose DasBlog for this blog is because it is text file based, not sql server based. Makes it a little easier on the setup side. DasBlog is also quite a bit less bulky than Community Server is, though it doesn't come with forums, file sharing, etc.

Slow Dasblog...

-- Filed Under: General
Comments: (0)
There are a couple things in this blogging app that are just moving horribly slow. Saving settings takes several minutes, as does the initial generation of an rss feed. If anybody else finds this annoying, sorry, but I will look into it.