?
Solved

Web Service Behavior in an ASP.NET User Control

Posted on 2004-09-03
10
Medium Priority
?
387 Views
Last Modified: 2010-05-18
I have not been able to come across any documentation describing how to invoke WebService behavior from inside a User Control.

The documentation dealing with using this behavior from within an ASP.NET page has you leverage the "onload" event of the <body> element of the page, as follows:

<body onload="init()">
  <div id="service" style="BEHAVIOR: url(webservice.htc)"></div>
</body>

where the function init() is defined in script as follows:

function init()
{
      // Create an instance of the web service and call it svcEmployee
      service.useService("SomeService.asmx?WSDL","someSvc");
}

As I understand, you do not have the luxury of using a <body> element when it comes to User Controls. My problem is how to invoke such an initialization function when I have no access/control to the page code.

Any help appreciated,
Satyen
0
Comment
Question by:hingos
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
10 Comments
 
LVL 26

Accepted Solution

by:
Rejojohny earned 1000 total points
ID: 11987668
where do u want to invoke the web service from? from the code-behind? if s, then y do u need the body tag? it is just like calling any web service ...

add a web reference of the web service u want to access
Create an instance of the proxy object in your code where you want to access the XML Web service.
Access the methods of the XML Web service as you would any other component.
0
 

Author Comment

by:hingos
ID: 11996132
Unfortunately I am not looking to invoke the web service from the code-behind. That would make the invocation run server-side.  The whole point of the Web Service "Behavior" support (developed by Microsoft), via the webservice.htc HTML component, is to enable client-side script to invoke remote methods exposed by Web Services.
0
 
LVL 26

Expert Comment

by:Rejojohny
ID: 11996154
u could use xmlhttp ...
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 26

Expert Comment

by:Rejojohny
ID: 12210486
Please have a look at my suggestion .. i ams sure it was an apt solution ...
0
 

Expert Comment

by:stuart_wachsberg
ID: 12230679
your solution lies in javascript, not codebehind.

see http://simon.incutio.com/archive/2004/05/26/addLoadEvent
0
 
LVL 26

Expert Comment

by:Rejojohny
ID: 12234597
that is esactly that i mentioned use javasript to instantiate xmlhttp object and call the web service .. not code-behind ..
0
 

Assisted Solution

by:stuart_wachsberg
stuart_wachsberg earned 1000 total points
ID: 12237704
Not exactly the same, Rejojohny. Satyen specifically wants to use the service behaviour described at :

http://msdn.microsoft.com/library/default.asp?url=/workshop/author/webservice/webservice_node_entry.asp

He has no interest in the xmlhttp com component.

To use the webservice behaviour described above, he needs to put some code in the Javascript onLoad event coded in the body tag.

His question then is more general than webservice usage: how can a control add to Javascript onLoad of the body tag?

The answer is to do it via a javascript assignement to window.onload, which, as I mentionned, is well-explained at  http://simon.incutio.com/archive/2004/05/26/addLoadEvent

The user control has the ability, via the RegisterClientScriptBlock, to place javascript code on the page. That javascript code can call window.onload. By transitivity, this implies that the user control can add to the onLoad of the body tag.


0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question