System.Web.UI.IStyleSheet.RegisterStyle Method

When implemented by a class, adds a new style rule to the embedded style sheet in the <head> section of a Web page.

Syntax

public void RegisterStyle (System.Web.UI.WebControls.Style style, IUrlResolutionService urlResolver)

Parameters

style
The style rule to be added to the embedded style sheet.
urlResolver
An System.Web.UI.IUrlResolutionService-implemented object that contains the context information for the current location (URL).

Remarks

This method adds a new style rule and System.Web.UI.WebControls.Style.RegisteredCssClass property name to the embedded style sheet within the <head> section of a System.Web.UI.Page object, and associates the rule with an auto-generated style name. The System.Web.UI.WebControls.Style object is rendered using the specified urlResolver parameter.

If urlResolver is set to null, the URL of the current System.Web.UI.Page is used.

If a System.Web.UI.WebControls.Style object is already registered, it is not added multiple times.

Note:

Adding or modifying styles programmatically during asynchronous postbacks is not supported. When you add AJAX capabilities to an ASP.NET Web page, asynchronous postbacks update regions of the page without updating the whole page. For more information, see ASP.NET AJAX Overview.

Requirements

Namespace: System.Web.UI
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 2.0.0.0
Since: .NET 2.0