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

Beginner - RadInputManager

1 Answer 77 Views
Input
This is a migrated thread and some comments may be shown as answers.
Al
Top achievements
Rank 1
Al asked on 30 Aug 2011, 01:04 PM
Hi,

This is the first time that i used Telerik Rad Controls, so i'm quite confused with some features.

What i want to do is :
I have 3 asp:TextBox, let's say, tbUserName, tbPostalCode and tbEmail.

And i would like to do a validation through 2 web services :
CheckUserNameExist(string email, string userName) and CheckUserRight(string email, string postalCode, string userName)

Actually i want to do it onBlur event, and call the web service only if the textboxes have values. I mean if the user enter email and username, it will call the first web service and if the user enter all the values in textboxes, then it will call the second web service.

I'm quite confuse on how i can achieve it ?

How can i pass the required parameters (email, username and postalcode) to my web service ? Must i do it through javascript ?

I'm thinking about this code.

<telerik:RadInputManager ID="radManager" runat="server">
        <telerik:TextBoxSetting Validation-IsRequired="true" Validation-Location="UserService.asmx"
            Validation-Method="CheckUserNameExist" Validation-ValidateOnEvent="Blur"
            BehaviorID="tbBehavior1"
        >
            <TargetControls>
                <telerik:TargetInput ControlID="tbEmail" />
                <telerik:TargetInput ControlID="tbUserName" />               
            </TargetControls>
        </telerik:TextBoxSetting>
       <telerik:TextBoxSetting Validation-IsRequired="true" Validation-Location="UserService.asmx"
            Validation-Method="CheckUserRight" Validation-ValidateOnEvent="Blur"
            BehaviorID="tbBehavior2"
        >
            <TargetControls>
                <telerik:TargetInput ControlID="tbEmail" />
                <telerik:TargetInput ControlID="tbUserName" />               
                <telerik:TargetInput ControlID="tbPostalCode" />               
            </TargetControls>
        </telerik:TextBoxSetting>
    </telerik:RadInputManager>
 
<asp:TextBox ID="tbEmail" runat="server"></asp:TextBox>
<asp:TextBox ID="tbUserName" runat="server"></asp:TextBox>
<asp:TextBox ID="tbPostalCode" runat="server"></asp:TextBox>

Thanks in advance, i hope you can help me out with this.

Regards,
Al

1 Answer, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 02 Sep 2011, 08:09 AM
Hello Al,

Check the demo about WebService validation using RadInpoutManager:
http://demos.telerik.com/aspnet-ajax/input/examples/radinputmanager/validationthroughwebservice/defaultcs.aspx
In order to pass some parameters to the service, you have to handle the onValidating client event of the TextBoxSetting, simillar to how it is done in the demo.
Then on the onValidating you could create an JavaScript associative array which to hold all values that you need later on server side. Then pass this array to set_context of the args parameter of the onValidating. Like in the example below.
function onValidating(sender, args) {
 
    var context = {};
    context["someKey"] = "some value";
    context["anotherKey"] = "another value";
    args.set_context(context);
 
}
Then in your service you could access this values like:
public bool CheckUserRight(string id, string value, object context)
{
 
     Dictionary<string, object> values = context as Dictionary<string, object>;
     string a = values["someKey"];
     string b = values["anotherKey"];  
}
Please examine the code of the online demo for working example.

Regards,
Vasil
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
Input
Asked by
Al
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Share this question
or