| |||||||||||||||||||||||||
Custom Server Control SyntaxASP.NET Syntax ASP.NET Page Syntax Defines user controls and user-authored server controls declaratively in a Web Forms page. <tagprefix:tagname id="accessID" attributename = "value" attributename-propertyname = "value" eventname = "eventhandlermethod" runat="server" /> or <tagprefix:tagname id="accessID" runat="server"> </tagprefix:tagname> Attributes
RemarksThe opening tags of these elements must include a runat="server" attribute/value pair. If you want to enable programmatic referencing on the control, specify a unique value with the id attribute. You must include an @ Register directive for each custom server control assembly and user control that you declare in a page. If you do not, a compilation error occurs. Any properties that you have authored on a custom server control can be exposed declaratively in the opening tag of the server control. Simply declare the property as an attribute and assign it a value. For example, if you create a custom text box control with a width property, declaring In some cases, attributes may be objects that have their own properties. In this case, include the property name in the declaration. For example, if you create a custom text box control that includes a font attribute, it can include a name property. You can then declare the property in the opening tag of the server control as You can also declare events with custom server controls and user controls in the same way you would with any ASP.NET server control. Simply specify the event binding in the opening tag of the server control with an attribute and value. For more information about writing event handlers, see Defining Web Forms Event-Handling Methods. For more information on authoring custom server controls that support events, see Web Forms Events and Handlers. You can also use and develop custom server controls that support inline templates. For details on how to declare templates in a custom server control, see Server Control Inline Template Syntax. To learn how to author custom server controls that support inline templates, see Developing Templated Controls. Syntax ExampleThe below code snippet demonstrates how you can register and declare a custom server control in a Web Forms page. The control's tag prefix is
See Also |
| ||||||||||||||||||||||||
Check out related books at Amazon
© 2000-2008 Rey Nuñez All rights reserved.
If you have any question, comment or suggestion
about this site, please send us a note
You can help support aspxtreme