Summary

Summary

Here s a summary of the important concepts presented in this chapter:

  • Custom controls are authored by deriving from System.Web.UI.Control.

  • A custom control overrides the Render method it inherits from Control to render itself to a Web page.

  • Implementing IPostBackDataHandler enables a control to update property values using data transmitted in postbacks and also to fire change events.

  • Controls that fire change events persist property values in view state in order to detect changes in property values.

  • Controls can force postbacks by rendering HTML elements that use client-side scripts to submit forms to the server. Page.GetPostBackEventReference outputs the postback script and returns code that calls the postback function.

  • Implementing IPostBackEventHandler enables a control to fire events when an element it rendered to a page causes a postback.

  • Composite controls serve as containers for other controls. A composite can be populated with child controls declaratively or programmatically.

  • Controls have the option of returning client-side script when they render themselves to a Web page. Page.RegisterClientScriptBlock ensures that functions returned in a script block are returned just once per request.

  • Controls can use the Browser property of the Request object to determine which type of browser submitted the request and adapt their output accordingly.

  • Graphical controls can be authored by returning <img> tags whose Src attributes reference image files stored on the server or HTTP handlers that generate images and return them to the client.

  • The @ Register directive enables custom controls to be used in Web forms.

Controls are the atoms from which Web forms are composed. Encapsulating complex rendering and behavioral logic in custom controls is a great way to share your knowledge with other developers and shield them from implementation details at the same time. As you design and implement controls of your own, keep in mind the principles discussed in this chapter. And feel free to use the samples contained herein as the basis for controls of your own.



Programming Microsoft  .NET
Applied MicrosoftNET Framework Programming in Microsoft Visual BasicNET
ISBN: B000MUD834
EAN: N/A
Year: 2002
Pages: 101

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net