RadAjaxManager and ASP.NET Validators

37 posts, 0 answers
  1. Chris Predeek
    Chris Predeek avatar
    9 posts
    Member since:
    Apr 2006

    Posted 17 Oct 2007 Link to this post

    Currently it seems that the ASP.NET Validators only work in server mode when used in the RadAjaxManager, but they work in client and server mode when in an UpdatePanel.

    We currently converting our from ASP.NET UpdatePanels and are wondering if we are missing something simple?  If not can we plan on client side validation in RadAjaxManager in the near future?

    Thanks,
    Chris
  2. Steve
    Admin
    Steve avatar
    10940 posts

    Posted 17 Oct 2007 Link to this post

    Hello Chris,

    RadAjax Prometheus is based on MS AJAX so we inherit its strengths and weaknesses. Validators are officially not supported by MS AJAX (http://asp.net/ajax/documentation/live/overview/UpdatePanelOverview.aspx) and therefore not supported by RadAjax Prometheus.

    Sincerely yours,
    Steve
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. Chris Predeek
    Chris Predeek avatar
    9 posts
    Member since:
    Apr 2006

    Posted 17 Oct 2007 Link to this post

    I understand that MS Ajax doesn't officially support client side validators, but they do work quite well inside an UpdatePanel.

    My question is are there any plans to replicate this behavior from the UpdatePanel in the RadAjaxManager or RadUpdatePanel?

    If a code example of validators working in the UpdatePanel would be helpful, let me know.

    Thanks,
    Chris
  4. Steve
    Admin
    Steve avatar
    10940 posts

    Posted 18 Oct 2007 Link to this post

    Hello Chris,

    In my previous reply, I have attached a sample page that works with RadAjaxManager and RadAjaxPanel and validators. Give it a spin and let us know of the outcome.

    All the best,
    Steve
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  5. Chris Predeek
    Chris Predeek avatar
    9 posts
    Member since:
    Apr 2006

    Posted 25 Oct 2007 Link to this post

    I looked at the example you sent and it seems that the example isn't using the new Prometheus controls set.  After more experimentation, I have more information on why client side validators are not working in the RadAjaxPanel but work fine in the UpdatePanel.  ASP.NET Validators use the Expando Attribute functionality in the ASP.NET AJAX ScriptManager.  When the validator is rendered it registers the attributes with the script manager.  When the ScriptManager renders, it writes the expando attributes to the response.

    When the ScriptManager is building an async response, it only emits the script for the expando attributes that are children of an UpdatePanel being refreshed.  The process it uses is to start at the expando attribute's control and work upwards through the control tree using the control's Parent attribute until it reaches the end or an update panel being refreshed.  When using the UpdatePanel this works fine since the update panel contains a reference to it's child tree in it's controls collection.

    The RadAjaxManager and RadAjaxPanel seem to use a mechanism where the UpdatePanel is created automatically and it's ContentTemplateContainer contains two controls, one of which contains a field referencing the UpdatePanel's content, but no reference in the controls collection (I assume that the special controls's render method manually calls the contained content's render method).  Since the control hierarchy between the validator and the update panel is broken, ASP.NET Ajax never renders any of the expando attributes since a path can't be traced from there to the update panel.

    I've tried to move the rendered content to the controls collection of the special control in the AjaxSettingsCreated event and successfully got the ExpandoAttributes returning in the async response, but unfortunately that's caused other problems.  Is there a known solution to this problem?

    Thanks,
    Chris

  6. Steve
    Admin
    Steve avatar
    10940 posts

    Posted 29 Oct 2007 Link to this post

    Hello Chris,

    Sorry for the wrong attachment. I have by mistake attached a page with the old RadAjax before the migration. Find attached the same functionality using the Prometheus RadAjax and let us know if having problems with this.

    Regards,
    Steve
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  7. Chris Predeek
    Chris Predeek avatar
    9 posts
    Member since:
    Apr 2006

    Posted 29 Oct 2007 Link to this post

    I've looked at the example you sent and it perfectly highlights the problem I've having.  Here are the steps to reproduce the problem.

    1. Enter valid values into the two text boxes.
    2. Cause a posback using the submit button.
    3. Change one of the entries to be empty.
    4. Try to submit again.  This time the validator will fire, but only server side.  Once an async postback has occurred, the client side validators won't work.

    Up until the async postback occurs the client side validation works perfectly.  If you replace the RadAjaxPanel with an UpdatePanel, the client side validators work fine after the async postback.

    Thanks,
    Chris
  8. Steve
    Admin
    Steve avatar
    10940 posts

    Posted 05 Nov 2007 Link to this post

    Hello Chris,

    Please comment out all the code in the RegisterButton_Click eventhandler and try following your steps again. You will notice that the client-side validation is fired as expected in this case as well.

    Sincerely yours,
    Steve
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  9. Chris Predeek
    Chris Predeek avatar
    9 posts
    Member since:
    Apr 2006

    Posted 05 Nov 2007 Link to this post

    I've tried what you suggested and it doesn't help the problem.  When I uncomment the lines in RegisterButton_Click and then reproduce my steps I get the same result from a network trace perspective.

    To see the problem more clearly, download fiddler and watch the network trace of http requests.  If you open your page and click register without entering any data you'll see that no http request is generated to the server to validate there is data in the text boxes.

    Once you enter valid data and force an async postback this changes.  From then on any time you click register with invalid data in the text boxes, a server request is made since the client side data structures aren't initialized property (the missing expando attributes in the async response).

    The problem I have is not with what is displayed in Label3 and Label4, my problem is related to a suite of client side script we use that interacts with validators.  Currently all of our scripts fail after an async postback due to the missing validator structures, but they work fine using an update panel. 

    Is there a way we can better connect to get you the information necessary to see the problem?

    Thanks,
    Chris
  10. jonnyO
    jonnyO avatar
    53 posts
    Member since:
    Jan 2004

    Posted 06 Nov 2007 Link to this post

    Hello Steve
    Okay, I have read these posts and your validation example (got VB?).   I spent a lot of time attempting to move my web app from "old" RadAjax to Prometheus only to find my validation heavy form elements and control events are ALL error prone.  I'm glad I found this post in time to save myself but the nagging question haunts me... will I eventually have to recode all my pages to accomodate MSAjax problems not experienced with Telerik Ajax (Pre-Prometheus - AjaxManager)?
    Thanks
    John
  11. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 09 Nov 2007 Link to this post

    Hello guys,

    You are right about this problem. We will do our best to provide fix as soon as possible - unfortunately due to the complexity of the dynamic update panels rendering we will need a bit more time to find clear working solution.

    Regards,
    Vlad
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  12. UT_DEV
    UT_DEV avatar
    20 posts
    Member since:
    Sep 2007

    Posted 28 Nov 2007 Link to this post

    Hello all we found a solution how to use client side validators, Ms unoffishally released a new version of Valdidators.
    Please use following dll in your solution
    http://blogs.msdn.com/mattgi/attachment/1516974.ashx

    and add following mappings to your web.config
          <tagMapping>
            <add tagType="System.Web.UI.WebControls.CompareValidator"           mappedTagType="Sample.Web.UI.Compatibility.CompareValidator, Validators, Version=1.0.0.0"/>
            <add tagType="System.Web.UI.WebControls.CustomValidator"            mappedTagType="Sample.Web.UI.Compatibility.CustomValidator, Validators, Version=1.0.0.0"/>
            <add tagType="System.Web.UI.WebControls.RangeValidator"             mappedTagType="Sample.Web.UI.Compatibility.RangeValidator, Validators, Version=1.0.0.0"/>
            <add tagType="System.Web.UI.WebControls.RegularExpressionValidator" mappedTagType="Sample.Web.UI.Compatibility.RegularExpressionValidator, Validators, Version=1.0.0.0"/>
            <add tagType="System.Web.UI.WebControls.RequiredFieldValidator"     mappedTagType="Sample.Web.UI.Compatibility.RequiredFieldValidator, Validators, Version=1.0.0.0"/>
            <add tagType="System.Web.UI.WebControls.ValidationSummary"          mappedTagType="Sample.Web.UI.Compatibility.ValidationSummary, Validators, Version=1.0.0.0"/>
          </tagMapping>


    And enjoy client side validator, hope this will help you
  13. Rob
    Rob avatar
    45 posts
    Member since:
    Sep 2007

    Posted 28 Nov 2007 Link to this post

    The actual blog entry relating to this is located here:

    http://blogs.msdn.com/mattgi/archive/2007/01/23/asp-net-ajax-validators.aspx

    I came across that entry in my search for a fix to my problem, and simply discarded it due to the the age of the post (Jan 2007) and the mention of it being included in a windows update, and the fact that in my particular scenario outlined in a separate support ticket which forwarded me to this link the standard ASP.NET Ajax panel was working, and it was a problem with Teleriks panel.

    I will implement the suggested code and report back.
  14. Rob
    Rob avatar
    45 posts
    Member since:
    Sep 2007

    Posted 28 Nov 2007 Link to this post

    Hi,

    Just to update this has had no impact on our problem, the client side validation is still not working as desired, and as working when using the standard asp.net ajax panel.
  15. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 30 Nov 2007 Link to this post

    Hi guys,

    Unfortunatelly you are right - we are still working on this issue and we will do our best to provide fix with Q3.

    Regards,
    Vlad
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  16. rdochert
    rdochert avatar
    82 posts
    Member since:
    Oct 2012

    Posted 17 Jan 2008 Link to this post

    was there an update for this? i'm not looking forward to retooling all of my radgrid edit forms which rely on validators heavily.
    rob
  17. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 22 Jan 2008 Link to this post

    Hi rdochert,

    We are still working on this subject because the problem appears to be more complex than we initially through. Hopefully the fix for the ASP.NET validators will appear in one of the next versions of RadAjax Prometheus. Please excuse us for the temporary inconvenience.

    Kind regards,
    Stephen
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  18. jonnyO
    jonnyO avatar
    53 posts
    Member since:
    Jan 2004

    Posted 22 Jan 2008 Link to this post

    Good to hear Stephen. 
    I will not be re-tooling with Prometheus until a work-around or "fix" addresses the client-side validation concern.
    Regards
    John
  19. rdochert
    rdochert avatar
    82 posts
    Member since:
    Oct 2012

    Posted 23 Jan 2008 Link to this post

    Thanks Stephen,
    it would be really cool if telerik could keep this thread updated so we all know where are with this. i'm sure this particular item of functionality would be keenly anticipated by many.
    cheers,
    rob

  20. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 06 Feb 2008 Link to this post

    Hello guys,

    I am pleased to inform you that we solved the problem with the ASP.NET validators and RadAjax Prometheus and the fix will be available officially for the Q3 2007 SP2 release, scheduled at the end of this month. For testing purposes I am attaching the latest internal trial build of RadControls Prometheus to this forum post. The build should be relatively stable and you can migrate to it until the fix becomes a fact.

    If this is something urgent for your development progress, please request a dev version of the hotfix via the support ticketing system. We will gladly provide it for you.

    Best regards,
    Stephen
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  21. Rob
    Rob avatar
    45 posts
    Member since:
    Sep 2007

    Posted 28 Feb 2008 Link to this post

    Hi,

    We have just upgraded to the latest Q2 2007 SP2 release and there seems to be progess on this, but it does not seem to completely resolved. I have created a new support ticket with a project attached.

    Rob
  22. Garry Clark
    Garry Clark avatar
    55 posts
    Member since:
    Jan 2005

    Posted 06 Jul 2008 Link to this post

    I am using 2008_1_619 version of the controls and it appears the validators still do not work. Any suggestions or updates on this issue?

    Thanks!
  23. Konstantin Petkov
    Admin
    Konstantin Petkov avatar
    1911 posts

    Posted 06 Jul 2008 Link to this post

    Hello Garry,

    A sample runnable project replicating the problem you experience will be much appreciated. Please, submit a formal support ticket where you can attach the necessary resources, thank you!

    Greetings,
    Konstantin Petkov
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  24. Rob
    Rob avatar
    23 posts
    Member since:
    Jul 2008

    Posted 17 Oct 2008 Link to this post

    I'm using Q1 2008 (version 2008.1.515.20) and my client-side validators don't work after the first Ajaxified postback.

    What's the latest on this?
  25. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 17 Oct 2008 Link to this post

    Hello Rob,

    The latest version of RadControls for ASP.NET AJAX is 2008.2.1001. Please migrate to this version following the instructions from the KB article linked below and let us know whether the validation works as expected:

    http://www.telerik.com/support/kb/article/b454K-kad-b454T-a-b454c-a.aspx

    Best regads,
    Stephen
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  26. Bryan
    Bryan avatar
    2 posts
    Member since:
    Jan 2008

    Posted 10 Jan 2009 Link to this post

    Stephen,
    I have been researching this for days and read this thread and it is the most updated info I can find.  I installed the latest version actually 1125 and still having a problem. Funny thing is that validation works correctly with RadAjaxUpdatePanel, but still not with RadAjaxManager.

    If you have a control in the panel that causes ajax postback and then a control outside that should cause validation and full postback the validation works fine only if there is no RadAjaxManager on the page.

    If I add a RadAjaxManager all ajax postbacks cause the validation to not work properly.   

    I have included the code for my test page. Currently it should bypass client validation on button 3 click after either button 1 or 2 has been clicked.  Simply comment out the RadAjaxManager and validation on button 3 works fine after an ajax postback from button 2.  Hopefully you can reproduce this from my code.

    Is this something that should be working now or is it still not supported?
    <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm1.aspx.vb" Inherits="TMPro.WebForm1" %> 
     
    <!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></title
    </head> 
    <body> 
        <form id="form1" runat="server"
        <asp:ScriptManager ID="ScriptManager1" runat="server"
            </asp:ScriptManager> 
        <div> 
            <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"
                <AjaxSettings> 
                    <telerik:AjaxSetting AjaxControlID="Button1" EventName="Click"
                        <UpdatedControls> 
                            <telerik:AjaxUpdatedControl ControlID="RadAjaxPanel1" /> 
                        </UpdatedControls> 
                    </telerik:AjaxSetting> 
                </AjaxSettings> 
            </telerik:RadAjaxManager> 
            <asp:Button ID="Button1" runat="server" CausesValidation="false" Text="First Button" /> 
            <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server"
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" Display="Dynamic" runat="server" ControlToValidate="TextBox2" ErrorMessage="Second text requires value."></asp:RequiredFieldValidator> 
                <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> 
                <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> 
                <asp:Button ID="Button2" runat="server" CausesValidation="false" Text="Second Button" /> 
            </telerik:RadAjaxPanel> 
             
                <asp:Button ID="Button3" runat="server" CausesValidation="true" Text="Third Button" /> 
        </div> 
        </form> 
    </body> 
    </html> 

    Public Partial Class WebForm1 
        Inherits System.Web.UI.Page 
     
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 
     
        End Sub 
     
        Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click 
            TextBox1.Text = "Button 1 Clicked" 
        End Sub 
     
        Private Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click 
            TextBox1.Text = "Button 2 Clicked" 
        End Sub 
     
        Private Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click 
            TextBox1.Text = "Button 3 Clicked" 
        End Sub 
    End Class 

    Thanks,
    Bryan
  27. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 12 Jan 2009 Link to this post

    Hello Bryan,

    From your code snippets I see that you specified the RadAjaxPanel as an updated control through the RadAjaxManager settings. Note that you can safely remove the RadAjaxPanel and replace it with standard asp Panel instead since the ajax manager will automatically inject MS UpdatePanel around the updated controls at runtime, namely:

    <asp:Panel ID="RadAjaxPanel1" runat="server">    
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" Display="Dynamic" runat="server" ControlToValidate="TextBox2" ErrorMessage="Second text requires value."></asp:RequiredFieldValidator>    
                <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>    
                <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>    
                <asp:Button ID="Button2" runat="server" CausesValidation="false" Text="Second Button" />    
    </asp:Panel>    
     

    Thus you will avoid nesting of MS UpdatePanels which is not necessary in this case. Let me know whether the validation works as expected after this modification.

    Best regards,
    Sebastian
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  28. Shrikant Kale
    Shrikant Kale avatar
    20 posts
    Member since:
    Oct 2009

    Posted 03 Dec 2009 Link to this post

    Hi,

    I went through the entire thread and tried out few things. I found that client validators do work even after post back, but there is one limitation. They do work only if submit button(which triggers the validation) is used as AjaxControlID in <AjaxSetting>.

    So If I have two submit buttons in one panel then for client validators to work correctly I will have to do two <AjaxSetting> entries, one for each button.

    I also observed that I  use simple AjaxPanel then all submmit buttons in panel work correctly. But If same panel is specified in list of <UpdatedControls> inside AjaxManager then things start going wrong.

    Is this an issue with ajax controls or I am missing something. Please point me to any information related to this.

    Regards
    Shrikant
  29. Pavel
    Admin
    Pavel avatar
    904 posts

    Posted 09 Dec 2009 Link to this post

    Hello Shrikant,

    You should not ajaxify RadAjaxPanel with RadAjaxManager as explained previously in this thread. RadAjaxManager wraps the ajaxified controls with MS UpdatePanel and thus you will have nested UpdatePanels which is not supported and is generally not advisable.

    All the best,
    Pavel
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  30. Shrikant Kale
    Shrikant Kale avatar
    20 posts
    Member since:
    Oct 2009

    Posted 09 Dec 2009 Link to this post

    Hi Pavel,

    Thanks for the reply. I understand ajaxifying radajaxpanel with ajax manager is not required and should be avoided.

    But my scenario is when I have a simple asp:Panel and there are two submit buttons in it. Now for client validators to work correctly I have to do two entries in ajax manager :

            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="button1" >
                    <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="panel"/>
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="button2" >
                    <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="panel"/>
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>

    If I dont do entry for "button2" then client validators on button2 don't work after postback.
    Is this a expected behavior or I am missing something?

    Regards
    Shrikant

Back to Top