p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/)
-   BOOK: Beginning ASP.NET 4.5.1 : in C# and VB (http://p2p.wrox.com/book-beginning-asp-net-4-5-1-c-vb-754/)
-   -   Chapter 15, Page 554 - Button Click Event (http://p2p.wrox.com/book-beginning-asp-net-4-5-1-c-vb/99582-chapter-15-page-554-button-click-event.html)

N_B July 20th, 2017 04:13 PM

Chapter 15, Page 554 - Button Click Event
 
I must be totally missing something, but I'm confused about these statements in the book:

On postback, the story looks quite different. When you click the button to cause a postback, the following events are raised:
...
GridView1_RowCreated
GridView1_RowCreated
GridView1_RowCreated
GridView1_RowCreated
Page_Load
Button1_Click
Page_PreRenderComplete
— — — — — — — — -

It’s important to understand and remember that user-triggered control events like a Button control’s Click or a SelectedIndexChanged of a DropDownList occur after the Load event of the Page.

-----------------------------------------------
But me clicking the button obviously initiates the PostBack. So how is the event happening after the subsequent load of the page? The click is what cause the page to load, no? Very confused.

Imar August 4th, 2017 04:10 PM

Yes, you clicking on the button happens first. However that happens on the server side. In order to respond to that click, the Click event fires on the server. But before that can happen, other stuff needs to happen first. The page doesn't have a button that can be clicked until it's loaded for example, so those events need to happen first.

Does that help?
Imar


All times are GMT -4. The time now is 06:46 AM.

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