Donate

ASP.NET Web Forms Multiple Server Validation Controls Wide Space Issue

Good day!

When working with multiple server validation controls for one input control, you often encountered wide space gap if the validation controls are placed inside a single container such as div or td such as the sample screenshot below.
ASP.NET Webform Multiple Server Validation Controls Wide Space Issue
The solution to remove the wide gap is to set the Display property of the validation controls to Dynamic.
<td>
 <asp:TextBox ID="txtCreditLimit" runat="server" Width="150" />
 <asp:RegularExpressionValidator ValidationGroup="valCustomerEntry" Display="Dynamic" ID="regexpName" runat="server" ErrorMessage="The value entered is not valid" 
   ControlToValidate="txtCreditLimit"  ValidationExpression="\d+(\.\d*)?|\.\d+" ForeColor="Red"/>
 <asp:RequiredFieldValidator ValidationGroup="valCustomerEntry" Display="Dynamic" ID="RequiredFieldValidator6" runat="server" ErrorMessage="Credit Limit cannot be blank" ControlToValidate="txtCreditLimit" ForeColor="Red"></asp:RequiredFieldValidator>  
</td>     
ASP.NET Webform Multiple Server Validation Controls Wide Space Issue
ASP.NET Webform Multiple Server Validation Controls Wide Space Issue
Notice that the Credit Limit field has multiple validation controls namely RequiredFieldValidator and RegularExpressionValidator.

Comments

Donate

Popular Posts From This Blog

WPF CRUD Application Using DataGrid, MVVM Pattern, Entity Framework, And C#.NET

TypeScript Error Or Bug: The term 'tsc' is not recognized as the name of a cmdlet, function, script file, or operable program.

Invalid nested tag div found, expected closing tag input