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

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

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:

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

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

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint