tailieunhanh - ASP.NET 4 Unleased - p 163

Building Custom Controls EnsureChildControls(); = value; } } protected override void CreateChildControls() { txtUserName = new TextBox(); = “txtUserName”; (txtUserName); txtPassword = new TextBox(); = “txtPassword”; = ; (txtPassword); } protected override void RenderContents(HtmlTextWriter writer) { (“float”, “left”); (); (, “3px”); (); (, ); (); (“User Name:”); (); (); (, “3px”); ();. | 1594 CHAPTER 36 Building Custom Controls EnsureChildControls value protected override void CreateChildControls txtUserName new TextBox txtUserName txtUserName txtPassword new TextBox txtPassword txtPassword protected override void RenderContents HtmlTextWriter writer float left 3px User Name 3px Password float left 3px writer From the Library of Wow eBook Overview of Custom Control Building 1595 3px writer br style clear left protected override HtmlTextWriterTag TagKey get return The control in Listing works quite nicely in all recent browsers Internet Explorer 6 Firefox Opera 8 without requiring an HTML table for layout see Figure . 36 FIGURE Performing CSS layout. From the Library of Wow eBook 1596 CHAPTER 36 Building Custom Controls View State and Control State The standard controls retain the values of .