This is a migrated thread and some comments may be shown as answers.

Required Field validator position

3 Answers 122 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Prachi
Top achievements
Rank 1
Prachi asked on 07 Aug 2012, 11:30 PM
Hi,

I am using template coulmn and adding required field validator and span tag to show * in red color.
I am struggling eith the allignment of the same. Please find attached the images depecting few cases.
I have tried adding br tag after span tag, after required field etc but it is not alligned properly.

All I am trying to implement is to have a Red * in the initial load of the page and required field error message on next line. I also need to take care of the scenario of people working on different resolution screen. I have 5 required fields.

<telerik:GridTemplateColumn HeaderText="Site ID" DataField="SiteID" UniqueName="SiteID"
                        EditFormColumnIndex="0" SortExpression="SiteID" AllowFiltering="true">
                        <EditItemTemplate>
                            <telerik:RadTextBox runat="server" ID="txtSiteId" Text='<%# Bind("SiteID") %>' MaxLength="50">
                            </telerik:RadTextBox>
                            <span style="color: red">*</span>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidatorSiteId" runat="server" ErrorMessage="Site Id is Required"
                                ControlToValidate="txtSiteId" ValidationGroup="requiredFieldGroup">
                            </asp:RequiredFieldValidator>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <%#Eval("SiteID")%>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 08 Aug 2012, 06:15 AM
Hi,

I have made some modifications in order to show the error message as in the screenshot. Here is the sample code.
aspx:
<telerik:GridTemplateColumn HeaderText="Site ID" DataField="SiteID" UniqueName="SiteID" EditFormColumnIndex="0" SortExpression="SiteID" AllowFiltering="true">
   <EditItemTemplate>
     <telerik:RadTextBox runat="server" ID="txtSiteId" Text='<%# Bind("SiteID") %>' MaxLength="50"></telerik:RadTextBox>
        <span style="color: red">*</span>
          <br />
    <asp:RequiredFieldValidator ID="RequiredFieldValidatorSiteId" runat="server" ErrorMessage="Site Id is Required" ControlToValidate="txtSiteId" ValidationGroup="requiredFieldGroup"></asp:RequiredFieldValidator>
   </EditItemTemplate>
   <ItemTemplate>
        <%#Eval("SiteID")%>
   </ItemTemplate>
</telerik:GridTemplateColumn>
Attached is the screenshot.

Thanks,
Shinu.
0
Prachi
Top achievements
Rank 1
answered on 08 Aug 2012, 08:44 PM
Thanks Shinu.

I had already tried the code suggested by you.
It works fine for only one field.

If I apply the <br/> in two consecutive fields then it appeares as attached image.

I am using following code :

<telerik:GridTemplateColumn HeaderText="Site ID" DataField="SiteID" UniqueName="SiteID"
                        EditFormColumnIndex="0" SortExpression="SiteID" AllowFiltering="true">
                        <EditItemTemplate>
                            <telerik:RadTextBox runat="server" ID="txtSiteId" Text='<%# Bind("SiteID") %>' MaxLength="50">
                            </telerik:RadTextBox>
                            <span style="color: red">*</span>
                            <br />
                            <asp:RequiredFieldValidator ID="RequiredFieldValidatorSiteId" runat="server" ErrorMessage="Site Id is Required"
                                ControlToValidate="txtSiteId" ValidationGroup="requiredFieldGroup"></asp:RequiredFieldValidator>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <%#Eval("SiteID")%>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn HeaderText="Site Name" DataField="Name" UniqueName="Name"
                        EditFormColumnIndex="0" SortExpression="Name" AllowFiltering="true">
                        <EditItemTemplate>
                            <telerik:RadTextBox runat="server" ID="txtSiteName" Text='<%# Bind("Name") %>' TextMode="MultiLine" Rows="2" MaxLength="100">
                            </telerik:RadTextBox>
                            <span style="color: red">*</span>
                            <br />
                            <asp:RequiredFieldValidator ID="RequiredFieldValidatorSiteName" runat="server" ErrorMessage="Site Name is Required"
                                ControlToValidate="txtSiteName" ValidationGroup="requiredFieldGroup"></asp:RequiredFieldValidator>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <%#Eval("Name")%>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
0
Kostadin
Telerik team
answered on 13 Aug 2012, 12:24 PM
Hi Prachi,

I was not able to reproduce your issue. I simply add <br /> tags after the <span> tags as Shinu suggested and everything works as expected. I prepared a small sample based on the information that you provided and attached it to this thread. Can you take a look at it and let me know how it differs from your real setup?

Kind regards,
Kostadin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Prachi
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Prachi
Top achievements
Rank 1
Kostadin
Telerik team
Share this question
or