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

Ajaxified customvalidator serverside validation

3 Answers 125 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Tobias
Top achievements
Rank 1
Tobias asked on 14 Oct 2009, 09:19 AM
Hi all,

I wonder if there is a possibility to do the following:
Have a textbox and a customvalidator.
Use serverside validation for both, client- and servervalidation
with the clientvalidation through an async server call.
I want to have one validation function on the server for both checks.

I want for example check the entered vale in the textbox against a sql database.

Thanks, Tobi

3 Answers, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 16 Oct 2009, 02:04 PM
Hello Tobias,

You can find attached a sample demo project demonstrating RadTextBox client and server side validation using CustomValidator control. The error message will be displayed if the value of the RadTextBox has changed and the Validate button is clicked.

I hope this helps.

Regards,
Martin
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
Tobias
Top achievements
Rank 1
answered on 16 Oct 2009, 02:35 PM
Thanks for your example. So far I know these things.
In the "ClientValidation.aspx" of your sample.zip you give the following lines:

        <asp:ScriptManager runat="server" ID="ScriptManager1">  
        </asp:ScriptManager> 
 
        <script type="text/javascript">  
            var invalidInput;  
            function ValueChanged(sender, args)  
            {  
                invalidInput = true;  
            }  
            function CustomValidate(sender, args)  
            {  
                if (invalidInput)  
                    args.IsValid = false;  
                invalidInput = false;  
            }   
        </script> 
 
        <telerik:RadTextBox ID="RadTextBox1" runat="server" > 
            <ClientEvents OnValueChanged="ValueChanged" /> 
        </telerik:RadTextBox> 
        <asp:CustomValidator ID="CustomValidator1" runat="server" ClientValidationFunction="CustomValidate" 
            ErrorMessage="Invalid" Display="Dynamic" /> 
        <asp:Button ID="Button1" runat="server" Text="Validate" /> 

In "function CustomValidate(sender, args)" I want to do an ajax check on the server e.g.
if (CheckIfUsernameIsInDataBaseServerSideAjaxCheck == true) {
    ...
} ...

I've already tried the use of Webservice or the ServerSideValidationExtender of "Validation Guidance Bundle" but I'd like to know your prefered methode to do such things because I didn't succeed with both mentioned doings.

Regards, Tobi

0
Martin
Telerik team
answered on 22 Oct 2009, 10:12 AM
Hello Tobias,

For WebService validation (client and server side) you should use a RadInputManager. For more details please check the attached sample project. You can also check the following online demo:

Validation through a web service

I hope this helps.

Regards,
Martin
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
Tobias
Top achievements
Rank 1
Answers by
Martin
Telerik team
Tobias
Top achievements
Rank 1
Share this question
or