Do this | |
---|---|
Create a control that can handle both client- and server-side events |
Modify an HTML control by right-clicking the control in Design view and selecting Run As Server Control (or by adding an id attribute and the runat=“server” attribute to the desired HTML element). Note that the element must support the desired client-side event. You can then add attributes to map the events to the appropriate client- and server-side event handlers. |
Show or hide an ASP.NET server control |
Modify the Visible property of the control. |
Add (or modify) an HTML attribute to an HTML control or Web control that is not exposed as a property of the control |
Add or modify the attribute by its name using the Attributes collection of the control: MyControl.Attributes(“Attribute”). Note that all attributes, including those exposed as properties on a control, are available via the Attributes collection. |
Apply styles to a control |
Set the Style or CssClass (Web controls only) of the control to the desired CSS style or class string. |
Validate user input |
Add a Validator server control to the page, and set its ControlToValidate property to the ID of the control the user will use to enter input. The type of control to use depends on what you want to validate. |