1 / 8

Chapter 6 Web Controls Detailed descriptions of server controls provided by FCL.

Chapter 6 Web Controls Detailed descriptions of server controls provided by FCL. Yingcai Xiao. Chapter 7 User Controls. Yingcai Xiao. User Controls. • Custom controls built from HTML and server-side scripts. • Create your own tags and tag prefixes. • File.ASCX A simple user control:

annice
Download Presentation

Chapter 6 Web Controls Detailed descriptions of server controls provided by FCL.

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 6Web ControlsDetailed descriptions of server controls provided by FCL. Yingcai Xiao

  2. Chapter 7 User Controls Yingcai Xiao

  3. User Controls • Custom controls built from HTML and server-side scripts. • Create your own tags and tag prefixes. • File.ASCX A simple user control: Hello.ascx <h1>Hello, world</h1>

  4. How to Use User Controls • Usage (UserControlDemo.aspx) <%@ Register TagPrefix="Xiao" TagName="Hello" src="Hello.ascx" %> <html> <body> <form RunAt="server"> <Xiao:Hello RunAt="server" /> </form> </body> </html> TagPrefix="Xiao" defines a new tag prefix. TagName="Hello" defines a new tag using src="Hello.ascx". http://winserv1.cs.uakron.edu/Examples/C6-7-8/UserControlDemo.aspx

  5. Chapter 8 Custom Controls Yingcai Xiao

  6. • Custom-built server controls using only a server-side language (no HTML). • Derived from System.Web.UI.Control. • Create your own tags and tag prefixes. Custom Controls

  7. Creation (Hello.cs) • using System; • using System.Web.UI; • namespace WP • { • public class Hello : Control • { • protected override void Render (HtmlTextWriter writer) • { • writer.Write ("Hello, world"); • } • } • } • Note: the Render method is required to be overridden. Custom Controls

  8. • Compilation: csc /target:library Hello.cs Move Hello.dll to “bin” of the application directory. • Usage http://winserv1.cs.uakron.edu/Examples/C6-7-8/CustomControlDemo.aspx <%@ Register TagPrefix="win" Namespace="WP" Assembly="Hello" %> <html> <body> <form RunAt="server"> <win:Hello RunAt="server" /> </form> </body> </html> Custom Controls

More Related