Beginner - RadInputManager

2 posts, 0 answers
  1. Al
    Al avatar
    13 posts
    Member since:
    Apr 2011

    Posted 30 Aug 2011 Link to this post

    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
  2. Vasil
    Admin
    Vasil avatar
    1638 posts

    Posted 02 Sep 2011 Link to this post

    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 >>

Back to Top