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
Solved

Web Service Behavior in an ASP.NET User Control

Posted on 2004-09-03
10
384 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

 
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

840 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