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

[Solved] RequiredFieldValidator and RadComboBox

5 Answers 327 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Guido Tapia
Top achievements
Rank 1
Guido Tapia asked on 20 Dec 2007, 03:48 AM
Hi required field validators and RadComboBox is not working as expected.  I have a page with:

<asp:RequiredFieldValidator ID="rfvValidator" runat="server" ControlToValidate="rcbComboBox" Display="Dynamic" InitialValue="--Select--" ErrorMessage="Please select a value" />

And

<telerik:RadComboBox ID="rcbComboBox" runat="server" AllowCustomText="False" />

The combo box is bound in the code behind.

However when the page is displayed the validators are shown.  They should only be shown after a selection has been made.

This worked fine in the RadControls.Net2 implementation.

Is there a known work around for this?

Thanks

Guido Tapia

5 Answers, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 20 Dec 2007, 07:11 AM
Hello Guido Tapia,

I tried to reproduce the problem, but to no avail. Attached, please find a small and running project on the matter.

If the InitialValue of the RequiredFieldValidator is set to the text of the first item that is selected by default upon page_load, the ErrorMessage will be shown when the page is loaded. You can set some custom text to the combobox (using the Text property of the control and enabling the AllowCustomText property) so that the ErrorMessage is not shown when page loads.

Hope this helps.

Regards,
Nick
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Guido Tapia
Top achievements
Rank 1
answered on 20 Dec 2007, 08:01 PM
I thought the problem was clear, I must not have explained myself well. Basically the expected behaiour of the RequiredFieldValidator is to warn you that you have not entered/selected anything in a required field.  It is not intended to tell you that you have not entered/selected something on initial page load as this is obvious.

Below is code that compares asp:DropDownList old radcontrol RadComboBox and telerik:RadComboBox (promethius).  You will see that promithius behaves incorrectly.

NOTE: Setting the AllowCustomText to true is not a solution, it is an ugly work around at best. A much nicer work around is to do server side validation.  I was hoping not to do that, so again I ask, is there any 'nice' work around to this bug.

Thanks

Guido Tapia

-------------------------------------------------------------------

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Test.aspx.cs" Inherits="Test" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<%@ Register TagPrefix="rad" Namespace="Telerik.WebControls" Assembly="RadComboBox.NET2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
<form id="f" runat="server">   
  <asp:ScriptManager id="sm" runat="server"/>  
  <asp:Button id="postback" runat="server" Text="Empty Postback Test" />
  <br/>
  <h2>Expected Behaviour</h2><br/>
  - Validator should not be shown on initial page load!!!!!!!
  <br/>
  <h1>asp:DropDownList</h1>
  <asp:DropDownList id="ddl1" runat="server">
   <asp:ListItem text="Select" />
   <asp:ListItem text="Item 1" />
   <asp:ListItem text="Item 2" />
   <asp:ListItem text="Item 3"/>
  </asp:DropDownList>
  <asp:RequiredFieldValidator id="v1" runat="server" Display="Dynamic" ErrorMessage="Error 1" ControlToValidate="ddl1" InitialValue="Select"/>
 
  <hr / >
  <h1>rad:RadComboBox (Old RadControls)</h1>
  <rad:RadComboBox id="ddl2" runat="server" AllowCustomText="false">
   <Items>
    <rad:RadComboBoxItem Text="Select" Selected="true"/>
    <rad:RadComboBoxItem Text="Item 1" />
    <rad:RadComboBoxItem Text="Item 2" />
    <rad:RadComboBoxItem Text="Item 3" />
   </Items>
  </rad:RadComboBox>
  <asp:RequiredFieldValidator id="v2" runat="server" Display="Dynamic" ErrorMessage="Error 2" ControlToValidate="ddl2" InitialValue="Select"/>
  
  <hr / >
  <h1>telerik:RadComboBox (Promithius)</h1>
  <telerik:RadComboBox id="ddl3" runat="server" AllowCustomText="false">
   <Items>
    <telerik:RadComboBoxItem Text="Select" Selected="true"/>
    <telerik:RadComboBoxItem Text="Item 1" />
    <telerik:RadComboBoxItem Text="Item 2" />
    <telerik:RadComboBoxItem Text="Item 3" />
   </Items>
  </telerik:RadComboBox>
  <asp:RequiredFieldValidator id="v3" runat="server" Display="Dynamic" ErrorMessage="Error 3" ControlToValidate="ddl3" InitialValue="Select"/>
 </form>
</body>
</html>

0
Rosi
Telerik team
answered on 21 Dec 2007, 01:22 PM
Hi Guido Tapia,

Thanks for bringing this to our attention. We will fix it for the service pack.


Regards,
Rosi
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Fernandes
Top achievements
Rank 1
answered on 27 Dec 2007, 05:57 PM
Good afternoon,


I'm having this problem too :(

The validator starts to show on the first page load.

We're in the middle of a development and we're about to buy the prometheus version...

How long will it take to release this service pack?

Fernandes
0
Rosi
Telerik team
answered on 28 Dec 2007, 10:28 AM
Hi ,

The service pack of Prometheus controls is scheduled to be released in the middle of January 2008.


Regards,
Rosi
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
ComboBox
Asked by
Guido Tapia
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Guido Tapia
Top achievements
Rank 1
Rosi
Telerik team
Fernandes
Top achievements
Rank 1
Share this question
or