Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8
This is the forum to discuss the Wrox book Beginning ASP.NET 2.0 by Chris Hart, John Kauffman, David Sussman, Chris Ullman; ISBN: 9780764588501
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old March 8th, 2010, 01:12 AM
Authorized User
 
Join Date: Jan 2010
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default Differences in how event handlers are created?

Hi All,

general quick question:

I am creating an event handler for the click of a button (eg: protected void Button1_Click(object sender, EventArgs e) - if I type the code from scratch it doesnt work when i generate the page, but if I double click the button on the design form to auto create the event handler it does work. How or why is it so?

I have created a form with 3 buttons and 3 labels as per do it yourself in chapter 9, p.338. I double clicked on the first two buttons to auto create the beginning of the event handler code, but for the third one I wrote the event handler code from scratch. The first two buttons changed the labels as it should have but the third button didnt work.

What exactly happens during the double click of the button to auto create the event handler code that doesnt happen when created manually?

It is not a completely crucial question but it is easier to copy and paste the bulk of the event handler code than it is to have to go back and forth between the design screen of the form and the code behind file.

Thanks,

Chris
Reply With Quote
  #2 (permalink)  
Old March 8th, 2010, 02:17 AM
Imar's Avatar
Wrox Author
Points: 67,704, Level: 100
Points: 67,704, Level: 100 Points: 67,704, Level: 100 Points: 67,704, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,282
Thanks: 66
Thanked 1,437 Times in 1,417 Posts
Default

Hi Chris,

It depends on the language you're using. In C#, the markup section of the control is modified:

<asp:Button ..... onclick="Button1_Click" .... />

In VB, in the Code Behind, the handler code is followed by the keyword Handles:

.... Button1_Click(.....) Handles Button1.Click

Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
  #3 (permalink)  
Old March 8th, 2010, 05:18 AM
Authorized User
 
Join Date: Jan 2010
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Imar,

thanks for that, I can say that I feel adequately stupid for not realising this before.

Thanks,

Chris
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
parameters in event handlers ajaxbeginner BOOK: Professional Ajax 2nd Edition ISBN: 978-0-470-10949-6 1 December 3rd, 2009 11:59 PM
Event handlers jwebb Visual Basic 2005 Basics 1 June 25th, 2007 09:44 PM
ie7 keycode, event handlers erobb Javascript 0 November 24th, 2006 01:37 PM
Event handlers does not work after some changes geetageetageeta ASP.NET 2.0 Basics 0 March 6th, 2006 04:19 AM
Conflicting Event Handlers chp Excel VBA 3 February 24th, 2006 03:00 PM



All times are GMT -4. The time now is 03:51 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.