Solved

Web Service Behavior in an ASP.NET User Control

Posted on 2004-09-03
10
385 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 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How come this regular expression allows "e"? 14 60
Add or delete table rows 10 64
Access is denied error from google drive api v2 in asp.net 1 46
orderby list (from Json) 1 31
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

730 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