asp:RequiredFieldValidator causing extra line in aspx page

I have simple ASPX page with few text buttons/drop downs. For almost every text button/drop down, I have the validators.

Issue I am facing is each of these validators produce a blank line on the page. Below is sample of the code in ASPX page. I tried with adding DISPLAY=DYNAMIC but I see blank lines getting reduced but when the validator message (or required * mark) is shown it shows that is not relevant near the textboxes.

            <tr>
            <asp:RequiredFieldValidator runat="server" ID="CityValidator" meta:resourceKey="CityValidator"
                ValidationGroup='<%# ValidationGroupName %>'  ControlToValidate="CityTextBox">*</asp:RequiredFieldValidator>
            <td>
                    <asp:TextBox runat="server" ID="CityTextBox" MaxLength='30' CssClass="TextBox" />
            </td>
                    <asp:RequiredFieldValidator runat="server" ID="RegionCodeValidator" meta:resourceKey="RegionCodeValidator"
                        ValidationGroup='<%# ValidationGroupName %>' ControlToValidate="RegionCodeTextBox" >*</asp:RequiredFieldValidator>
            <td>
                    <asp:TextBox runat="server" ID="RegionCodeTextBox" MaxLength='2' CssClass="TextBox"/>
            </td>
        </tr>

Answers


Set the validator display as dynamic. You should also put the validators within the table structure to keep your HTML structure valid.

   <tr>
        <td>
                <asp:RequiredFieldValidator runat="server" ID="CityValidator" meta:resourceKey="CityValidator" Display="Dynamic" ValidationGroup='<%# ValidationGroupName %>'  ControlToValidate="CityTextBox">*</asp:RequiredFieldValidator>
                <asp:TextBox runat="server" ID="CityTextBox" MaxLength='30' CssClass="TextBox" />
        </td>
        <td>
                <asp:RequiredFieldValidator runat="server" ID="RegionCodeValidator" meta:resourceKey="RegionCodeValidator" Display="Dynamic" ValidationGroup='<%# ValidationGroupName %>' ControlToValidate="RegionCodeTextBox" >*</asp:RequiredFieldValidator>
                <asp:TextBox runat="server" ID="RegionCodeTextBox" MaxLength='2' CssClass="TextBox"/>
        </td>
    </tr>

Need Your Help

Trying to perform a a linq query that joins two tables, has a where clause, and groups the results

sql-server linq linq-to-sql

I am sure it is a simple, but I can't quite get it to work. This is the SQL query I am using as my reference. I want to make this same thing happen with LINQ.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.