Passing parameters to webservice

7 posts, 0 answers
  1. Telerikuser
    Telerikuser avatar
    35 posts
    Member since:
    May 2009

    Posted 24 Jul 2009 Link to this post

    Can you provide me a sample code to pass parameters to my webservice using XMLHTTPPanel.

    Thanks
  2. Obi-Wan Kenobi
    Obi-Wan Kenobi  avatar
    460 posts
    Member since:
    Aug 2007

    Posted 30 Jul 2009 Link to this post

    You can find such an example here:
    http://demos.telerik.com/aspnet-ajax/xmlhttppanel/examples/clientsidecontentload/defaultcs.aspx

    This is the code which is responsible to send a parameter to the server

    <script type="text/javascript">  
            function rowSelected(sender, args) {  
                var key = args.getDataKeyValue("CustomerID");  
                var panel = $find("<%=RadXmlHttpPanel1.ClientID %>");   
                panel.set_value(key); // key will be sent to sever  
            }  
        </script> 

    In the server handler you can get the "key" value

    protected void XmlHttpPanel_ServiceRequest(object sender, RadXmlHttpPanelEventArgs e)  
            {  
                string val = e.Value;//this is the "key"  
    ...................  

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Amir
    Amir avatar
    15 posts
    Member since:
    Sep 2006

    Posted 13 Aug 2009 Link to this post

    Hi,
    The example you provided is for passing parameters using callback method, is there anyway to pass parameters to the web service introduced by WebMethodName.
    Thanks
  5. Tervel
    Admin
    Tervel avatar
    1337 posts

    Posted 14 Aug 2009 Link to this post

    Hi Amir,

    The default RadXmlHttpPanel demo features a Web service.
    Please take a look at the second RadXmlHttpPanel on the right side of the example.
    The demo is part of the trial RadControls installation - so you can download it at examine all the related files on your own machine.

    Best wishes,
    Tervel
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  6. Mojo
    Mojo avatar
    10 posts
    Member since:
    Oct 2006

    Posted 17 Aug 2009 Link to this post

    Hi,

    Tervel I'm having problems with the demo you suggested. I use webservice too. Problem is that my webservice needs a string as parameter and the RadXmlHttpPanel automatically calls the webservice on page load (with no parameters). Therefor when loading my page I get an:

    Invalid web service call, missing value for parameter: 'user'.

    How can I avoid this error?

    Thx
    Mojo
  7. Lini
    Admin
    Lini avatar
    2144 posts

    Posted 18 Aug 2009 Link to this post

    Hello Mojo,

    I already answered your support ticket, but I will also post here so other people can benefit from the information as well:

    The demo page that Tervel linked to includes one XmlHttpPanel, which calls a web service. The parameter for the web service is set in the panel's Value property - either on the client - panel.set_value("test") - or on the server - panel.Value = "test". You can pass the user information in the value and read it on the server in the web method. The code for this in the linked example is in our demo application - the ~\App_Code\ToolTipWebService.cs file and the GetCustomersByCountryXmlHttpPanel() method.

    Regards,
    Lini
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  8. Mojo
    Mojo avatar
    10 posts
    Member since:
    Oct 2006

    Posted 18 Aug 2009 Link to this post

    Hi Lini,

    Yes thank you!

    I really miss small demoes (like a Hello World + yourname demo) in both vb and c# instead of complicated c# demoes ... and the online help for XmlHttpPanel is terrible. I know you're working on it, but for the end user it's really important to have it up front ... ever bought a vcr and had the manual dillevered 1-2 months later? ;)

    Well your reply on my ticket was perfect! - just sad that I spent so much time trying to figure it out myself.

    :)
    Mojo
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017