Applying a Special CSS Style Sheet on Selected Pages

In some case, you might need to apply a special CSS style sheet on certain pages instead of using the stylesheet in the App_Theme folder.  To do this, you need to customize two methods, Page_InitializeEventHandlers, and Page_PreInit in your code behind .aspx.cs or .aspx.vb.

Updated April 29, 2011
Iron Speed Designer V8.0 and later


    public void Page_InitializeEventHandlers(object sender, System.EventArgs e) {
        //  Handles MyBase.Init. 
        //  Register the Event handler for any Events.
        this.Page_InitializeEventHandlers_Base(sender, e);
        //  here is how you add <link href="../css/fancyforms.css" rel="stylesheet" type="text/css" /> to your applicaiton
        HtmlLink css = new HtmlLink();
        css.Href = "../css/fancyforms.css";
        css.Attributes["rel"] = "stylesheet";
        css.Attributes["type"] = "text/css";
    public void Page_PreInit(object sender, System.EventArgs e) {
        // Override call to PreInit_Base() here to change top level master page used by this page.
        // For example for SharePoint applications uncomment next line to use Microsoft SharePoint default master page
        // If Not Me.Master Is Nothing Then Me.Master.MasterPageFile = Microsoft.SharePoint.SPContext.Current.Web.MasterUrl    
        // You may change here assignment of application theme
        try {
            //  disable .net theme
            this.Theme = "";
        catch (Exception ex) {


Visual Basic .NET:

      Public Sub Page_InitializeEventHandlers(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Init

            ' Handles MyBase.Init.

            ' Register the Event handler for any Events.

            Me.Page_InitializeEventHandlers_Base(sender, e)


            ' here is how you add <link href="../css/fancyforms.css" rel="stylesheet" type="text/css" /> to your applicaiton

            Dim css As HtmlLink = New HtmlLink()

            css.Href = "../css/fancyforms.css"

            css.Attributes("rel") = "stylesheet"

            css.Attributes("type") = "text/css"


        End Sub


      Public Sub Page_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit

          'Override call to PreInit_Base() here to change top level master page used by this page.

          'For example for SharePoint applications uncomment next line to use Microsoft SharePoint default master page

          'If Not Me.Master Is Nothing Then Me.Master.MasterPageFile = Microsoft.SharePoint.SPContext.Current.Web.MasterUrl    

          'You may change here assignment of application theme




                ' disable .net theme

                Me.Theme = ""


          Catch ex As Exception


          End Try               

      End Sub