Solved

Web Service Behavior in an ASP.NET User Control

Posted on 2004-09-03
10
379 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

747 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now