DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Wed, 1 Aug 2007 21:40:01 -0700,    posted on: microsoft.public.dotnet.framework.aspnet.buildingcontrols        back       

Thread Index
  1    Chuck P am
          2    (Walter Wang [MSFT])
                 3    Chuck P am
                        4    (Walter Wang [MSFT])
                               5    (Walter Wang [MSFT])
                               6    Chuck P am
                               7    (Walter Wang [MSFT])


Custom Control Embedded CSS   
I have a control that has an embedded CSS file.
I override the  OnPreRender event and put in the following code:

HtmlLink cssLink = new HtmlLink();
.....  get the resource, create the link
Page.Header.Controls.Add(cssLink);
base.OnPreRender(e);

This works fine at runtime.
However at design time the CSS does not get applied.

Whats the best way to get the CSS applied at design time?

thanks,
Date:Wed, 1 Aug 2007 21:40:01 -0700   Author:  

RE: Custom Control Embedded CSS   
Hi Chuck,

This is a quick note to let you know that I am performing research on this 
issue and will get back to you as soon as possible. I appreciate your 
patience. 


Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Date:Thu, 02 Aug 2007 09:59:23 GMT   Author:  

RE: Custom Control Embedded CSS   
I guess OnPreRender doesn't fire in design mode.

http://www.manuelabadia.com/blog/PermaLink,guid,8cdc7001-bca7-4ea6-a3f8-0fb2861548f6.aspx
Date:Thu, 2 Aug 2007 07:30:02 -0700   Author:  

RE: Custom Control Embedded CSS   
Hi Chuck,

Yes my test also verified that OnPreRender is not called in design-time. 
I'm also tried other approaches but still no luck, I'm currently consulting 
this question within our internal discussion list. I'll keep you posted. 
Thank you for your patience.

Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Date:Fri, 03 Aug 2007 07:23:07 GMT   Author:  

RE: Custom Control Embedded CSS   
Hi Chuck,

It seems we will have to use a custom control designer to make the 
stylesheet work at design-time, and we must use inline style instead:

        public override string GetDesignTimeHtml()
        {
            return "<style> .highlight {background-color: yellow} </style>" 
+ base.GetDesignTimeHtml();
        }

This is not very elegant but so far this seems the only way to make the 
stylesheet works at design-time.

Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Date:Mon, 06 Aug 2007 09:11:44 GMT   Author:  

RE: Custom Control Embedded CSS   
Thanks Walter,
I wasn't aware of that event.
I did something similar with checking for Design mode in the render event 
and putting in a link to an embedded style sheet.

        private string GetCssLink()
        {  
            string strFooterCssLocation = CssLocation; //empty unless user 
overrides location from the embedded style sheet

            if (string.IsNullOrEmpty(strFooterCssLocation))
                strFooterCssLocation = 
Page.ClientScript.GetWebResourceUrl(this.GetType(), 
@"Util_Controls.LanlFooter.css");

            return strFooterCssLocation;
        }


        protected override void RenderContents(HtmlTextWriter output)
        {
            if (DesignMode)
            {  //at runtime PreRender is fired and we put the link in the head
                output.Write(" <link href=\"" + GetCssLink() + "\" 
rel=\"stylesheet\" type=\"text/css\" />");
            }
Date:Mon, 6 Aug 2007 07:36:00 -0700   Author:  

RE: Custom Control Embedded CSS   
Hi Chuck,

Thanks for sharing your solution here. I think it's better than having to 
write a custom control designer.

Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Date:Tue, 07 Aug 2007 02:18:20 GMT   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us