spacer
Yehuda Shiran July 31, 2002
The onclick Event Handler
Tips: July 2002

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
Eclipse Helios Update Brings New PHP Tools
Internet Explorer 9 Ups Standards Support
JBoss Portal 5 Release Easier to Use

When consuming the add Web service, we call the JScript .NET function, Submit_Click(). It is the event handler of the ASP:BUTTON control. Here is the code:

  public function Submit_Click(sender:Object, E:EventArgs) : void {
    var result : String;
    var webService : simpleCalc;
    webService = new simpleCalc();
  
    result = webService.add(int.Parse(first.Text), int.Parse(second.Text)).ToString();
    resultControl.Text = result;
  }
We define an object webService of the simpleCalc class. The class simpleCalc is the Web service class, and is stored in the simpleCalc namespace of the .NET framework. We call the Web service by calling the add() method of the object webService. We pass the two input integer numbers to add(). The value of the ASP:TEXTBOX control is its Text field. Therefore, the two input numbers are first.Text and second.Text. Since they are textual entries, we need to parse them as integer values by sending them to the method int.Parse().

The answer sent back by the Web service is stored in result. Finally, the value of result is written in the ASP:TEXTBOX entry of resultControl.

To learn more about JScript .NET and ASP.NET, go to Column 113, JScript .NET, Part VII: Consuming add from ASP.NET.


People who read this tip also read these tips:

Look for similar tips by subject:

webref The latest from WebReference.com Browse >
Flashmaps' DynamicLocator: Interactive Maps for Small Areas · Flashmaps' AreaSelector: Interactive Maps for Wide Areas · The DB Mapper: Interactive Street-level Maps of U.S. and Canada
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
MS Access and MySQL · Cisco AutoQoS: VoIP QoS for Mere Mortals · While VoIP Adoption Explodes in Enterprise, Carrier Spending Lags