160 likes | 381 Views
Chapter 7- Building User Controls and Custom Web Controls. User Controls. Reduce duplication of effort Maintains site consistency Examples controls: Header/Footer Address entry Validation. User Control Creation. Requires .ascx extension Web User Control. User Control .
E N D
User Controls • Reduce duplication of effort • Maintains site consistency • Examples controls: • Header/Footer • Address entry • Validation
User Control Creation • Requires .ascx extension • Web User Control
User Control <%@ Control Language="vb" AutoEventWireup="false" Codebehind="MyControl.ascx.vb" Inherits="Ch07Web.MyControl" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %> <P> Name: <asp:TextBox id="TextBox1" runat="server"> </asp:TextBox> </P>
User Control … <%@ Register TagPrefix="uc1" TagName="MyControl" Src="MyControl.ascx" %> … <form id="Form1" method="post" runat="server"> <uc1:MyControl id="MyControl1" runat="server"> </uc1:MyControl> </form>
Web Server Controls • More time to create • Implement Render( ) method • Inherits System.Web.UI.Control or • Inherits System.Web.UI.WebControls.WebControl