TAILIEUCHUNG - ASP.NET 4 Unleased - p 35

Creating Custom Controls with User Controls AssociatedControlID=”txtCity” Runat=”server” / | 314 CHAPTER 7 Creating Custom Controls with User Controls AssociatedControlID txtCity Runat server div div class addressField asp TextBox ID txtCity Runat server asp RequiredFieldValidator ID reqCity Text required ControlToValidate txtCity Runat server div br class clear div class addressLabel asp Label ID lblState Text State AssociatedControlID txtState Runat server div div class addressField asp TextBox ID txtState Runat server asp RequiredFieldValidator ID reqState Text required ControlToValidate txtState Runat server div br class clear div class addressLabel asp Label ID lblPostalCode Text Postal Code AssociatedControlID txtPostalCode Runat server div div class addressField asp TextBox ID txtPostalCode From the Library of Wow eBook Creating User Controls 315 Runat server asp RequiredFieldValidator ID RequiredFieldValidator1 Text required ControlToValidate txtPostalCode Runat server div br class clear fieldset The AddressForm control contains form controls for entering your street city state and postal code. Each of these fields is validated by a RequiredFieldValidator control. Finally the AddressForm includes a Label that can provide a title for the control. The AddressForm exposes all its form fields with properties. The control includes public Street City State and PostalCode property which you can read from the containing page. The page in Listing illustrates how you can use the AddressForm control in a page. LISTING @ Page Language C @ Register TagPrefix user TagName AddressForm Src DOCTYPE html PUBLIC - W3C DTD XHTML EN http TR xhtml11 DTD script runat server protected void btnSubmit_Click object sender EventArgs e Show Billing Address Form Results br Billing Street br Billing City br Billing State br Billing Postal Code br br 7 .