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: Professional ASP.NET 2.0 Server Control and Component Development ISBN: 978-0-471-79350-2
This is the forum to discuss the Wrox book Professional ASP.NET 2.0 Server Control and Component Development by Dr. Shahram Khosravi; ISBN: 9780471793502
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET 2.0 Server Control and Component Development ISBN: 978-0-471-79350-2 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
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 27th, 2006, 01:45 PM
Authorized User
 
Join Date: Sep 2006
Location: , , .
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chp. 4 pg.97 Custom controls

This end of this chapter discusses how the developer can replace the hardcoded html tags with server controls,then says that the IPostBackEventHandler.RaisePostBackEvent method does not need to be implemented because the Web.UI.Button control implements the same interface..

My question is, what code exactly should be removed and/or updated for this to happen? I replaced the html tags with server controls for this chapter and called their RenderControl method (and passed in the HtmlTextWriter as a parameter)

The author kind of left the reader in a lurch when he discussed this alternative by not explaining the changes in the code? Does the event handling verson of the custom control class need to declare the event object keys and all that stuff? The methods in the IPostBackEventHandler interface?

  #2 (permalink)  
Old October 3rd, 2006, 11:10 AM
Authorized User
 
Join Date: Sep 2006
Location: , , .
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok, this is kinda simple. does the author even check these forums? (Actually its Chp. 5, Pg 97) IS there anyway to contact him directly?

  #3 (permalink)  
Old October 3rd, 2006, 02:16 PM
Wrox Author
 
Join Date: Aug 2006
Location: , , .
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi studen77,

The section immediately after the paragraph that you mentioned in your first post provides you with a detailed recipe for developing custom composite controls, which also includes a section on events. As I've discussed in that section, event bubbling is the highly recommonded approach to implementing events in composite controls.

Another approach is what I mentioned briefly in the paragraph that you refered to. This approach is very simple to implement but it is not recommonded. I mentioned this approach as an example to make the point that your custom composite control doesn't need to implement the IPostBackEventHandler interface.

Cheers,
Shahram

------------------------
Shahram Khosravi, Ph.D.
Author of Professional ASP.NET 2.0 Server Control and Component Development
  #4 (permalink)  
Old October 4th, 2006, 08:53 AM
Authorized User
 
Join Date: Sep 2006
Location: , , .
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you for your reply, Shahram--

The problem is that I'm kind of pressed for time and I had gotten deep into the first method of creating server controls from *scratch* and implementing the event handling manually. While I can accept your opinion that this is "not" the recommended approach, it would have helped to explain to the reader everything that they would need to know to go this route.

Moreover, your example custom control was very OVERLY SIMPLISTIC...I was developing a control with multiple <input> html buttons that would have to raise postback events and handle these events accordingly. In your simple example control, you have a single button which has its 'name' attribute set to the UniqueID of the control itself, which I'm sure left several readers in the dark when they had multiple buttons within their control.

What you should have done is have the reader set the <input 'type'> attribute to button and add the 'onclick' attribute, passing the 'Page.ClientScript.GetPostBackEventReference' method passing the control's reference to itself and an identifier for the button or object that caused it to the 'RaisePostBackEvent' method. This would allow the control to identify exactly which control raised the postback event.

I ended up having to go to http://www.code-magazine.com/Article...ickid=0511051" which explained this the right way.

You honestly caused me hours of confusion when you totally abandoned the reader by not even FULLY explaining the proper way to create controls manually with their own event handling..specifically with your overly-simplistic credit card entry control with a single button..

  #5 (permalink)  
Old October 4th, 2006, 03:39 PM
Wrox Author
 
Join Date: Aug 2006
Location: , , .
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You mentioned that you're pressed for time. I'm a developer just like you. As a developer, I quite understand how frustrating things could get when we're faced with deadlines and pressed for time. I wish you luck with your project. Now back to the issues you raised in your posts.

You mentioned that I don't cover cases where more than one button is used. I'm surprised to hear that because numerous chatpers in this book cover this case. As a matter of fact, this book shows you how to develop custom controls as complex as GridView where ton of buttons are used. By the way, event bubbling is not a matter of personal opinion. It is an integral part of the ASP.NET server control architecture. As a matter of fact, the standard ASP.NET composite controls that come with the ASP.NET Framework use event bubbling to map the events raised by their child Button, ImageButton, and LinkButton controls (or in general any control that implement IButtonControl interface) to top level events. I've discussed event bubbling extensively in Chapter 4.

You also mentioned that the first few examples are overlly simplistic. Since this book is for the ASP.NET developer who wants to learn how to build server controls and components for the first time, it's natural for the book to begin with simple examples. However, the rest of this book is packed with complex, real-world custom controls. Those readers that know the materials covered in the first few chapters can skip these introductory chapters and go directly to more advanced chapters of the book where they learn how to develop complex server controls such as custom GridView, Ajax-enabled controls, data-bound Web Parts controls, etc.

I wish you the best,

Cheers!
Shahram




-----------------------
Shahram Khosravi, Ph.D.
Author of Professional ASP.NET 2.0 Server Control and Component Development
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
Chp.12 'custom' SqlDataSource and paging studen77 BOOK: Professional ASP.NET 2.0 Server Control and Component Development ISBN: 978-0-471-79350-2 8 April 4th, 2007 05:49 PM
Custom Controls apry BOOK: Beginning ASP.NET 1.0 2 May 23rd, 2004 11:04 PM



All times are GMT -4. The time now is 08:27 AM.


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