London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!
AI OnAI Off
London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!
// Inside an User Control inheriting
// from UserControlBase
((TemplatePage)this.PageBase).RegisterCssFile("...");
Are you suggesting adding the RegisterCssFile method to the UserControlBase class?
Parent.Controls.Clear();
It would remove yourself from the control tree, which could be a problem for later rendering :-)
So, you can still use RegisterCssFile method, just make sure the user control you call it from is not inside the head tag.
If your code will always be somewhere inside the head tag, you really don't need the RegisterCssFile, as its prime purpose is to make sure the css file is only included once, and that the tag is placed inside the head tag, regardless from where you call it. In this case, a literal will be more effective.
Just remember to put the runat="server" attribute on the head tag, if not, EPiServer won't find it, and no css file will be linked. In this case, the call returns false, and you could throw an exception.
/Steve