To stop the unnecessary spaces rendered while the page is loading and when there is no validation error, you need set the value of the Display
property to Dynamic
:
<tr>
<td width="40%" class=postheader><%# GetText("username") %>:<font color="red">*</font></td>
<td class=post_alt>
<asp:TextBox id=UserName runat="server" Width="100%" />
<asp:RequiredFieldValidator runat="server" Display="Dynamic" ErrorMessage='User Name is required.' ControlToValidate="UserName" EnableClientScript="False"/>
</td>
</tr>
<tr>
<td class=postheader><%# GetText("password") %>:<font color="red">*</font></td>
<td class=post_alt>
<asp:TextBox id=Password runat="server" TextMode="Password" Width="100%" />
<asp:RequiredFieldValidator runat="server" Display="Dynamic" ErrorMessage='Password is required.' ControlToValidate="Password" EnableClientScript="False"/>
</td>
</tr>
<tr>
<td class=postheader><%# GetText("retype_password") %>:<font color="red">*</font></td>
<td class=post_alt>
<asp:TextBox id=Password2 runat="server" TextMode="Password" Width="100%" />
<asp:CompareValidator runat="server" Display="Dynamic" ErrorMessage='Passwords didn't match.' ControlToValidate="Password2" ControlToCompare="Password" EnableClientScript="False"/>
</td>
</tr>
<tr>
<td class=postheader><%# GetText("email") %>:<font color="red">*</font></td>
<td class=post_alt>
<asp:TextBox id=Email runat="server" Width="100%"/>
<asp:RequiredFieldValidator runat="server" Display="Dynamic" ErrorMessage='Email Address is required.' ControlToValidate="Email" EnableClientScript="False"/>
</td>
</tr>
The default value is "static" which reserves the space and causes the white space rendered.
If you don't type some value in the required text boxes when you click the submit button, the validation error message will be displayed below the text boxes: