Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Embedded CSS not working during designtime [modified]

Embedded CSS not working during designtime [modified]

Scheduled Pinned Locked Moved ASP.NET
designcsswpfhardwarehelp
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Fayu
    wrote on last edited by
    #1

    I have an embedded css resource which contains styling info for a table. When I run my app, the table is shown with the styles specified. During design time, these styles are not applied to my table. More info below. I think my problem may be that the OnPreRender may not be run during design time. What are my options? Thanks in advance. assembly.cs: [assembly: WebResource("MyNamespace.StyleSheet.css", "text/css", PerformSubstitution=true)] MyControl.cs:

        void RegisterStyleSheet()
        {
            string includeTemplate =
                "";
            string includeLocation =
                  Page.ClientScript.GetWebResourceUrl(this.GetType(), "MyNamespace.StyleSheet.css");
            LiteralControl include =
                  new LiteralControl(String.Format(includeTemplate, includeLocation));
            ((System.Web.UI.HtmlControls.HtmlHead)Page.Header).Controls.Add(include);
        }
    
        protected override void OnPreRender(EventArgs e)
        {
            RegisterStyleSheet();
    
    
            base.OnPreRender(e);
        }
    

    modified on Friday, July 9, 2010 1:54 PM

    F 1 Reply Last reply
    0
    • F Fayu

      I have an embedded css resource which contains styling info for a table. When I run my app, the table is shown with the styles specified. During design time, these styles are not applied to my table. More info below. I think my problem may be that the OnPreRender may not be run during design time. What are my options? Thanks in advance. assembly.cs: [assembly: WebResource("MyNamespace.StyleSheet.css", "text/css", PerformSubstitution=true)] MyControl.cs:

          void RegisterStyleSheet()
          {
              string includeTemplate =
                  "";
              string includeLocation =
                    Page.ClientScript.GetWebResourceUrl(this.GetType(), "MyNamespace.StyleSheet.css");
              LiteralControl include =
                    new LiteralControl(String.Format(includeTemplate, includeLocation));
              ((System.Web.UI.HtmlControls.HtmlHead)Page.Header).Controls.Add(include);
          }
      
          protected override void OnPreRender(EventArgs e)
          {
              RegisterStyleSheet();
      
      
              base.OnPreRender(e);
          }
      

      modified on Friday, July 9, 2010 1:54 PM

      F Offline
      F Offline
      Fayu
      wrote on last edited by
      #2

      Figured it out. I changd the RegisterStyleSheet to return a string:

          string RegisterStyleSheet()
          {
              string includeTemplate =
                  "";
              string includeLocation =
                    Page.ClientScript.GetWebResourceUrl(this.GetType(), "Fyuzon.Membership.Web.Css.BaseGridStyleSheet.css");
              return String.Format(includeTemplate, includeLocation);
          }
      

      and override the RenderControl with the following:

          public override void RenderControl(HtmlTextWriter writer)
          {
              writer.Write(this.RegisterStyleSheet());
              base.RenderControl(writer);
          }
      

      Works like a charm... If there is a better way of doing this, please do let me know.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups