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

RadGrid embedded RequiredFieldValidator Text property not working

6 Answers 90 Views
Grid
This is a migrated thread and some comments may be shown as answers.
JJ
Top achievements
Rank 1
JJ asked on 05 Nov 2012, 03:13 PM
I am using a RequiredFieldValidator and a ValidationSummary within a usercontrol within RadGrid EditForm.

The validation works fine, but I have set the RequiredFieldValidator to show an * beside the control being validated (Text="*") and the ErrorMessage to something more discriptive: ErrorMessage="Name is required."

The problem however is that when the cotrol errors out, ErrorMessage shows in both the ValidationSummary and next to the erroring control where the * is expected per the property  (Text="*"). I need the * to show because it is better for my layout and consistent with validation outside the radgrid elsewhere on the page. The longer more verbose Message="Name is required."
messes up the layout.

Has anyone had this problem before. I have never seen the RequiredFieldOperator behave like this before so I can only see the RadGrid as being the problem.

Someone please help.

6 Answers, 1 is accepted

Sort by
0
Angel Petrov
Telerik team
answered on 08 Nov 2012, 12:12 PM
Hi JJ,

Based on the information provided I can not tell for sure what exactly is causing the problematic behaviour. Could you please elaborate a bit more on the exact scenario you are implementing? If you could send us you aspx code as well as the related code behind we would be able to give you a more clear answer why this issue occurs.

Regards,
Angel Petrov
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.
0
JJ
Top achievements
Rank 1
answered on 08 Nov 2012, 02:14 PM
OK, let me repeat myself.

I have a RadGrid, for which I am using a UserControl as the EditForm (declaration follows):

<

EditFormSettings EditFormType="webUserControl" UserControlName="~/UserControls/uc_Steps_Party.ascx"></EditFormSettings>

In the UserControl I am implementing standard .Net validation with standard .Net controls, namely the ValidationSummary and the RequiredFieldValidator (declaration follows along with the btn that causes the validation):

 

<asp:ValidationSummary runat="server"  
ValidationGroup="vg"

ShowSummary="true"
HeaderText="Please fix the following fields:"

DisplayMode="List"

/>

<asp:DropDownList ID="ddl" runat="server" Visible="False" Width="200px" CssClass="select"/>

<asp:RequiredFieldValidator ID="rfv" runat="server"
InitialValue=""
ControlToValidate="ddl"
ValidationGroup="vg"
Enabled="True"
CssClass="error_msg"
Text="*"

ErrorMessage="Field required."
/>

 
<asp:Button runat="server" ID="btn" CommandName="Update" Visible="false" Text="Save" ValidationGroup="vg" CausesValidation="true"/>

At runtime, when the ddl above errors out, the (ErrorMessage="Field required.") is shown beside the ddl, not the expected (Text="*"). The property set for (Text="*") is the expected string that is set shown inline where the RequiredFieldValidator is declared. The (ErrorMessage="Field required.") property should only show inline where the ValidationSummary is declared, not in both places, as I am experiencing in a UserControl embedded in a RadGrid.

If you are not familar with this standard .Net validation behavior, take the code above and place it on a form by itself outside a RadGrid and validate it. You will see that only (Text="*") will show next to the ddl where the RequiredFieldOperator is declared and (ErrorMessage="Field required.") will show where the ValidationSummary is declared. That is the way .Net validation has always worked for me before I used a RadGrid.

0
Angel Petrov
Telerik team
answered on 13 Nov 2012, 08:04 AM
Hello JJ,

Based on your code I have created a simple example using RadGrid and a web user control and it behaves as expected. Please review it and find what differs in your case. Could you also confirm that the web user control behaves this way only when used in RadGrid? If the problem still persist please open a formal support ticket with an attached project replicating this issue. In the meantime you can examine the project that is attached to this post.

All the best,
Angel Petrov
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.
0
JJ
Top achievements
Rank 1
answered on 13 Nov 2012, 02:15 PM
I am unable to make your example work. Can you send an entire project/solution file?
0
Angel Petrov
Telerik team
answered on 13 Nov 2012, 04:16 PM
Hello JJ,

The project in the ZIP file is a simple website which you could open using the following steps:
  1. Extract the ZIP file somewhere on your machine
  2. Open Visual Studio
  3. Select - File -> Open -> Web Site...
  4. Add the necessary assemblies to the BIN folder (Telerik.Web.UI at minimum)

Kind regards,
Angel Petrov
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.
0
JJ
Top achievements
Rank 1
answered on 13 Nov 2012, 04:17 PM
OK, nevermind about the project/solution. I got the code to work but I had to change the DataSource of the RadGrid. Yes it did work as expected, which made me dig deeper into my problem. I have a more complicated issue in that my architecture is more complicated....

My validators are whithn a usercontrol withing an editform of a radgrid, that we have established and per your code it should work. ...What's more the user control contains another usercontrol containing a linkbtn and a modalpopup that I believe is causing the problem upon further testing...The second embedded usercontrol contains a link button on the initial user control that calls a modalpopup which in turn the user searches for data on then ultimately clicks a button and their found data populates the usercontrol and the modalpopup is hidden. It is at the hiding of the modalpopup and the manipulation of the data being shoved back into the radgrid/usercontrol that somehow garbles the RequiredFieldOperaors's Text and ErrorMessage properties. The ErrorMessage property always wins out and the Text property is ignored....so that is the fuller issue. If I simply validate the radgrid/usercontrol without the intervening ModalPopup, the validation works fine...the Text and ErrorMessage properties remain distinct and work as expected. The ModalPopup close btn click and hiding changes the expected behavior.

Tags
Grid
Asked by
JJ
Top achievements
Rank 1
Answers by
Angel Petrov
Telerik team
JJ
Top achievements
Rank 1
Share this question
or