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

Required Field Validators and AJax

2 Answers 87 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
mac
Top achievements
Rank 1
mac asked on 11 Aug 2008, 09:28 PM
heya.
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 
        Else  
            frm1.FindControl("Enddate").Visible = False 
            frm1.FindControl("rfEnddate").Visible = False 
            frm1.FindControl("lblEndDate").Visible = False 
 
                  End If 

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

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

Thanks
mac

2 Answers, 1 is accepted

Sort by
0
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.

Greetings,
Maria Ilieva
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
mac
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" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<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 
        Else  
            RadDatePicker1.Visible = False 
            Me.RFDate.Enabled = False 
            RFDate.Visible = False 
        End If  
        ScriptManager1.DataBind()  
          
          
    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  
</script> 
 
<html xmlns="http://www.w3.org/1999/xhtml" > 
<head runat="server">  
    <title>Untitled Page</title> 
</head> 
<body> 
    <form id="form1" runat="server">  
        <asp:ScriptManager ID="ScriptManager1" runat="server">  
        </asp:ScriptManager> 
    <div> 
    <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> 
</Items> 
 
<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
</telerik:radcombobox> 
        <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> 
</telerik:raddatepicker> 
        <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">  
            <AjaxSettings> 
                <telerik:AjaxSetting AjaxControlID="RadComboBox1">  
                    <UpdatedControls> 
                        <telerik:AjaxUpdatedControl ControlID="MSG" /> 
                        <telerik:AjaxUpdatedControl ControlID="RadDatePicker1" /> 
                        <telerik:AjaxUpdatedControl ControlID="RFDate" /> 
                    </UpdatedControls> 
                </telerik:AjaxSetting> 
            </AjaxSettings> 
          
        </telerik:RadAjaxManager> 
          
          
          
          
          
          
        </div> 
    </form> 
</body> 
</html> 
 


Tags
Ajax
Asked by
mac
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
mac
Top achievements
Rank 1
Share this question
or