Solved

Web Service Behavior in an ASP.NET User Control

Posted on 2004-09-03
10
382 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
  • 4
  • 2
10 Comments
 
LVL 26

Accepted Solution

by:
Rejojohny earned 250 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

777 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