spacer
Yehuda Shiran September 6, 2002
Handling Click Events in a Windows form
Tips: September 2002

Yehuda Shiran, Ph.D.
Doc JavaScript

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

To associate an event handler with a button, you first need to add the event handler to the button. Let's assume the button is button1 and the event handler is button1_Clicked:

  button1.add_Click(button1_Clicked); 
Then, we define the event handler to pop-up an alert box whenever the button is clicked:

  function button1_Clicked(o : Object, e : EventArgs) {
    MessageBox.Show(o.Name());
  }  
The package is ButtonClickPkg and the class is ButtonClickCls. We pop up the Windows form by calling the Application.Run() method:

  Application.Run(new ButtonClickPkg.ButtonClickCls());
You should get the following Windows form:

To learn more about JScript .NET and ASP.NET, go to Column 117, JScript .NET, Part XI: Creating Windows Forms.


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