Online courses in ASP.NET MVC, ASP.NET Core, and Design Patterns conducted by Bipin Joshi. Read more...
Learn ASP.NET MVC, ASP.NET Core, and Design Patterns through our online training programs. Courses conducted by Bipin Joshi on weekends. Read more details here.

Calling A Web Services using Web Service Behavior

The Problem

Recently I came across a client requirement, where I needed to fetch small piece of data from a web service, and display it on a web form, without page getting posted back.

The Solution

The problem was resolved with the help of Web Behaviors. Web service behaviors - also called as HTC - are reusable DHTML components that uses Web Service to transfer SOAP data on HTTP. In this solution , web page gets small JavaScript , which calls web method or web service on server. It gets data which is displayed on the web form in browser. All this happens without page being posted back.

The Code Download

The sample code available for download along with this article contains a web form with a HTML button. On the click of this button client side JavaScript is fired. This JavaScript calls web service on the server and gets the data.Web service is returning latest DateTime. Note that we need to keep a file called webservice.htc with the web form which uses the web service behavior.
 




Nitin Mekhiya is presently working with Cap gemini Consulting.Nitin has fascination for .Net technology and subjects like OOAD , Design patterns and software Architecture.

Posted On : 02 Jan 2005



Tags : ASP.NET Web Services JavaScript