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

Required Field Validators and AJax

2 Answers 87 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
mac asked on 11 Aug 2008, 09:28 PM
4 ctrls
Status (RadComboBox) ("Regular","Temporary")
LblEnddate (Label)
EndDate (RadDatepicker)
rfEnddate (required Field  bound to Enddate)

If all visible set to true, field is required, however when visible = false, field is not required...(logical)
 Protected Sub Status_SelectedIndexChanged(ByVal o As Object, ByVal e As Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs)  
        If InStr(e.Value, "Temporary") Then  
            frm1.FindControl("Enddate").Visible = True 
            frm1.FindControl("rfEnddate").Visible = True 
            frm1.FindControl("lblEndDate").Visible = True 
            frm1.FindControl("Enddate").Visible = False 
            frm1.FindControl("rfEnddate").Visible = False 
            frm1.FindControl("lblEndDate").Visible = False 
                  End If 

the ajax block
  <telerik:AjaxSetting AjaxControlID="Status">  
                           <telerik:AjaxUpdatedControl ControlID="lblEndDate" /> 
                           <telerik:AjaxUpdatedControl ControlID="RFEndDate" /> 
                           <telerik:AjaxUpdatedControl ControlID="EndDate" /> 

the visible switch is working fine... however the requiredfield event is not raising. Thoughts ?


2 Answers, 1 is accepted

Sort by
Maria Ilieva
Telerik team
answered on 12 Aug 2008, 08:03 AM
Hello mac,

Please note that ASP Standard Validators on the client are officially not supported with Ajax.
However please try to add the Validators into the RadAjaxManager settings. The validators and the corresponding controls should be updates together.

Maria Ilieva
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Top achievements
Rank 1
answered on 12 Aug 2008, 03:58 PM
Sorry.. I am not getting this. I redid an extremely dumbed down sample to post here and get the following errors/odditites back. 
RFDate (required validator) is disabled
RadDatePicker is visible =False

if user selects Regular from combo box, page posts back. If user selects temporary, rfdate and radDatePicker are enabled and Visible. (this works.... the first time...
once the page is posted back however, the SelectedIndexChanged event is lost ??  This may appear quite simple however the answer is deceiving me.

entire source posted: (msg label is for debugging purposes)
<%@ Page Language="VB" %> 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""> 
<script runat="server">  
    Protected Sub RadComboBox1_SelectedIndexChanged(ByVal o As Object, ByVal e As Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs)  
        If e.Text = "Temporary" Then  
            Me.RadDatePicker1.Visible = True 
            Me.RFDate.Enabled = True 
            RFDate.Visible = True 
            RadDatePicker1.Visible = False 
            Me.RFDate.Enabled = False 
            RFDate.Visible = False 
        End If  
    End Sub  
    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)  
        MSG.Text = Date.Now.ToString  
    End Sub  
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)  
        MSG.Text = Date.Now  
    End Sub  
<html xmlns="" > 
<head runat="server">  
    <title>Untitled Page</title> 
    <form id="form1" runat="server">  
        <asp:ScriptManager ID="ScriptManager1" runat="server">  
    <asp:Label ID="MSG" runat="Server"></asp:Label> 
        <telerik:radcombobox AutoPostBack="true" id="RadComboBox1" runat="server" OnSelectedIndexChanged="RadComboBox1_SelectedIndexChanged"><Items> 
<telerik:RadComboBoxItem runat="server" Text="Select" Selected="True"></telerik:RadComboBoxItem> 
<telerik:RadComboBoxItem runat="server" Text="Regular"></telerik:RadComboBoxItem> 
<telerik:RadComboBoxItem runat="server" Text="Temporary"></telerik:RadComboBoxItem> 
<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
        <asp:RequiredFieldValidator ID="RFCombo" runat="server" ControlToValidate="RadComboBox1" 
            ErrorMessage="combo required" InitialValue="Select"></asp:RequiredFieldValidator> 
        <br /> 
        <telerik:raddatepicker id="RadDatePicker1" runat="server" visible="False">  
<DateInput InvalidStyleDuration="100"></DateInput> 
        <asp:RequiredFieldValidator ID="RFDate" runat="server" ControlToValidate="RadDatePicker1" 
            ErrorMessage="you must have a date" Enabled="False"></asp:RequiredFieldValidator><br /> 
        <br /> 
        <br /> 
        <br /> 
        <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /> 
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">  
                <telerik:AjaxSetting AjaxControlID="RadComboBox1">  
                        <telerik:AjaxUpdatedControl ControlID="MSG" /> 
                        <telerik:AjaxUpdatedControl ControlID="RadDatePicker1" /> 
                        <telerik:AjaxUpdatedControl ControlID="RFDate" /> 

Asked by
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Top achievements
Rank 1
Share this question