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

RadAjaxManager and ASP.NET Validators

36 Answers 939 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Chris Predeek
Top achievements
Rank 1
Chris Predeek asked on 17 Oct 2007, 08:57 AM
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

36 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 17 Oct 2007, 11:51 AM
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
0
Chris Predeek
Top achievements
Rank 1
answered on 17 Oct 2007, 04:23 PM
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
0
Steve
Telerik team
answered on 18 Oct 2007, 11:08 AM
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
0
Chris Predeek
Top achievements
Rank 1
answered on 26 Oct 2007, 02:49 AM

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

0
Steve
Telerik team
answered on 29 Oct 2007, 03:18 PM
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
0
Chris Predeek
Top achievements
Rank 1
answered on 29 Oct 2007, 09:50 PM
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
0
Steve
Telerik team
answered on 05 Nov 2007, 06:50 AM
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
0
Chris Predeek
Top achievements
Rank 1
answered on 05 Nov 2007, 03:39 PM
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
0
jonnyO
Top achievements
Rank 1
answered on 06 Nov 2007, 05:10 PM
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
0
Vlad
Telerik team
answered on 09 Nov 2007, 02:58 PM
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
0
UT_DEV
Top achievements
Rank 1
answered on 28 Nov 2007, 09:18 AM
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
0
Rob
Top achievements
Rank 1
answered on 28 Nov 2007, 09:29 AM
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.
0
Rob
Top achievements
Rank 1
answered on 28 Nov 2007, 09:41 AM
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.
0
Vlad
Telerik team
answered on 30 Nov 2007, 03:46 PM
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
0
rdochert
Top achievements
Rank 1
answered on 17 Jan 2008, 08:22 PM
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
0
Sebastian
Telerik team
answered on 22 Jan 2008, 04:14 PM
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
0
jonnyO
Top achievements
Rank 1
answered on 22 Jan 2008, 06:51 PM
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
0
rdochert
Top achievements
Rank 1
answered on 23 Jan 2008, 09:32 AM
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

0
Sebastian
Telerik team
answered on 06 Feb 2008, 01:27 PM
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
0
Rob
Top achievements
Rank 1
answered on 28 Feb 2008, 11:29 AM
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
0
Garry Clark
Top achievements
Rank 1
answered on 07 Jul 2008, 02:12 AM
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!
0
Konstantin Petkov
Telerik team
answered on 07 Jul 2008, 04:53 AM
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
0
Rob
Top achievements
Rank 1
answered on 17 Oct 2008, 11:20 AM
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?
0
Sebastian
Telerik team
answered on 17 Oct 2008, 11:28 AM
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.
0
Bryan
Top achievements
Rank 1
answered on 10 Jan 2009, 03:57 PM
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
0
Sebastian
Telerik team
answered on 12 Jan 2009, 12:07 PM
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.
0
Shrikant Kale
Top achievements
Rank 1
answered on 04 Dec 2009, 03:27 AM
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
0
Pavel
Telerik team
answered on 09 Dec 2009, 07:41 AM
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.
0
Shrikant Kale
Top achievements
Rank 1
answered on 09 Dec 2009, 08:12 AM
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

0
Pavel
Telerik team
answered on 14 Dec 2009, 11:55 AM
Hello Shrikant,

I am attaching a sample page which seems to work as expected on my end without the additional setting. Take a look at it and let me know how to alter it in order to replicate the behavior.

Sincerely yours,
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.
0
Shrikant Kale
Top achievements
Rank 1
answered on 15 Dec 2009, 04:27 AM
Hi Pavel,

Thanks a lot for reply.

I looked at the example. I had to change it for correcting the ID of panel in AJAXManager. I changed the line
<telerik:AjaxUpdatedControl ControlID="Panel" />  

to
<telerik:AjaxUpdatedControl ControlID="Panel1" />  

After this change, panel got actuallly ajaxified.

Now here are the steps I follow
1) Do not enter any value in textbox2 and click button2, error will appear page will not be posted. This is as expected.
2) Now enter some value in textbox2 and click button2, page will get posted. This is as expected.
3) Now do not enter any value in textbox2 and click button2, page will get posted ! This is not what I expect.

What I can conclude from this is, validator is not working correctly after postback.

If I follow same steps with button1, then every time textbox2 is blank I get error no matter whether page is already posted.

If I uncomment the lines which have ajaxsettings for button2, then button2 also starts behaving as expected.

Regards
Shrikant

0
Pavel
Telerik team
answered on 15 Dec 2009, 07:36 AM
Hello Shrikant,

I am sorry for this omission on my part. Indeed I was able to observe the behavior. The problem is that in this case the validator does not get properly updated and that is necessary as it is the control which allows or denies the postback. You can see that it works if you add the following settings:
<telerik:AjaxSetting AjaxControlID="Button2" >
    <UpdatedControls>
        <telerik:AjaxUpdatedControl ControlID="RequiredFieldValidator1" />
    </UpdatedControls>
</telerik:AjaxSetting>

Depending on your needs you should add a setting which includes Button2 to update the validator, as  you have found out yourself. I hope this explanation is helpful.

Best wishes,
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.
0
Shrikant Kale
Top achievements
Rank 1
answered on 15 Dec 2009, 08:24 AM
Hi Pavel,

Thanks for confirming this behavior.

I have one more question. Instead of entering validator as updated control in AjaxManager I am making two entries as follows

<AjaxSettings>  
<telerik:AjaxSetting AjaxControlID="Button1" >  
    <UpdatedControls>  
        <telerik:AjaxUpdatedControl ControlID="Panel1" />  
    </UpdatedControls>  
</telerik:AjaxSetting>  
<telerik:AjaxSetting AjaxControlID="Button2" EventName="Click">  
    <UpdatedControls>  
        <telerik:AjaxUpdatedControl ControlID="Panel1" /> 
    </UpdatedControls>  
</telerik:AjaxSetting> 
</AjaxSettings>  

This makes all validators in panel run correctly.

Just wanted to know whether this will create any problem?

Regards
Shrikant
0
Pavel
Telerik team
answered on 15 Dec 2009, 08:33 AM
Hello Shrikant,

Your approach is valid and should not create any problems.

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.
0
Vivek
Top achievements
Rank 1
answered on 23 Dec 2012, 07:25 PM
I am getting the different behavior. My validator are not firing for the first time but start firing after post back. Actually, I see in the markup on the first page load, expando attributes are not getting assigned to my custom validator but I see the expando attributes appended after the post back. I am using client side validation.

I am using this version - 2008.2.826.35
0
Pavlina
Telerik team
answered on 26 Dec 2012, 08:20 AM
Hello Vivek,
The version of our suite which you are using in your project is no longer supported. This is why, I would highly recommend upgrading to our latest version and see if the problem you are facing still persists. If you have any questions, during the upgrade process, do not hesitate to contact us.

All the best,
Pavlina
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.
Tags
Ajax
Asked by
Chris Predeek
Top achievements
Rank 1
Answers by
Steve
Telerik team
Chris Predeek
Top achievements
Rank 1
jonnyO
Top achievements
Rank 1
Vlad
Telerik team
UT_DEV
Top achievements
Rank 1
Rob
Top achievements
Rank 1
rdochert
Top achievements
Rank 1
Sebastian
Telerik team
Garry Clark
Top achievements
Rank 1
Konstantin Petkov
Telerik team
Rob
Top achievements
Rank 1
Bryan
Top achievements
Rank 1
Shrikant Kale
Top achievements
Rank 1
Pavel
Telerik team
Vivek
Top achievements
Rank 1
Pavlina
Telerik team
Share this question
or