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

Passing parameters to webservice

6 Answers 277 Views
XmlHttpPanel
This is a migrated thread and some comments may be shown as answers.
Telerikuser
Top achievements
Rank 1
Telerikuser asked on 24 Jul 2009, 02:01 PM
Can you provide me a sample code to pass parameters to my webservice using XMLHTTPPanel.

Thanks

6 Answers, 1 is accepted

Sort by
0
Obi-Wan Kenobi
Top achievements
Rank 1
answered on 30 Jul 2009, 09:15 AM

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

0
Amir
Top achievements
Rank 1
answered on 13 Aug 2009, 09:37 PM
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
0
Tervel
Telerik team
answered on 14 Aug 2009, 07:28 AM
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.
0
Mojo
Top achievements
Rank 1
answered on 17 Aug 2009, 08:34 AM
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
0
Lini
Telerik team
answered on 18 Aug 2009, 10:58 AM
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.
0
Mojo
Top achievements
Rank 1
answered on 18 Aug 2009, 11:12 AM
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
Tags
XmlHttpPanel
Asked by
Telerikuser
Top achievements
Rank 1
Answers by
Obi-Wan Kenobi
Top achievements
Rank 1
Amir
Top achievements
Rank 1
Tervel
Telerik team
Mojo
Top achievements
Rank 1
Lini
Telerik team
Share this question
or