spacer
Yehuda Shiran July 13, 2002
Calling the IsPrime Web Service from DHTML
Tips: July 2002

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?

In Column 106 we explained how to consume Web services through Microsoft Internet Explorer. There are three HTML items you need to add to your page to enable it to consume Web services:

  • onload="init()". Add this event handler to your BODY tag. For example:

      <BODY BGCOLOR="#ffffff" onload="init()">
  • Instantiate the webservice behavior. You can share this behavior among all Web services you consume from your page:

      <DIV ID="myWebService" STYLE="behavior:url(webservice.htc)"></DIV>
  • GUI. Implement some way to collect user parameters and display the results. Simple INPUT elements will do.

The isprime TABLE has two rows. The first row includes an entry field for the number to be tested and a button to invoke the check. The second row includes a DIV element that displays the answer, via an innerHTML update. The ID of the input field is "testValue" and the ID of the result DIV is "theResult2". The button calls isPrimeNumber() when clicked. Here is the HTML code:

  <TABLE BORDER="0">
    <TR>
      <TD>Enter a number:</TD>
      <TD><INPUT SIZE="4" TYPE="text" ID="testValue" VALUE="0"></TD>
      <TD> </TD>
      <TD><INPUT VALUE="Click here to check if prime" 
	   TYPE="button" onclick="isPrimeNumber();"></TD>
    </TR>
    <TR><TD COLSPAN=4><DIV ID="theResult2"></DIV></TD></TR>
  </TABLE>
To learn more about JScript .NET, go to Column 112, JScript .NET, Part VI: Creating IE Web Services.


People who read this tip also read these tips:

Look for similar tips by subject:

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business