For example, we have some CSS rules to define our form layout. We use the following markup:
<div class='foo'> <label class='bar req'>Name<em>*</em></label> <span> <asp:TextBox runat='server'/> <label>First</label> </span> <span> <asp:TextBox runat='server'/> <label>Last</label> </span> <div class='clear'></div> </div>
In my opinion, this is perfectly fine markup. Following these rules is not a burden since you’re supposed to worry about clean, correct markup anyway. It’s being suggested that we ‘enforce’ these rules with a control that looks something like the following:
<x:FormField runat='server' Label='Name' Required='True'> <x:TextBox runat='server' hint='First'/> <x:TextBox runat='server' hint='Last'/> </x:FormField>
My instinct tells me that XHTML markup is our friend, not our enemy. Two questions:
- Am I completely off base to resist making all these custom controls just to emit markup?
- If you agree with me, what reasons would you give?
I vote use the controls, because if that markup ever changed (say you wanted to add some nice jQueryUI effects to the boxes or add a RequiredFieldValidator control) you can make the change in one place and be done with it. DRY.