gvspm
-
11/16/2006 10:09:21 AM
Re: ASP.NET master pages
Hello,
thanks for your explanation and yes, i can switch away form classic asp.net master pages and use kentico's philosophy of master pages. I like this approach very much!
<preface> I started to build our new portal with Kentico 1.9 (demo). Now i try to migrate to 2.0 (demo for now) In 1.9 i wrote my code logic directly in the .aspx template and this In my eyes, allowed me to easely debug it in vs2005. But now i have to separate all my code in nice Webparts, and i am facing a steep learning curve. </preface>
So, in a WebPart, how can i access the head ?
You suggested in post <a href="http://www.kentico.com/Forums/ShowPost.aspx?PostID=2151">Post 2151 - Modifying the <head> tag</a> to modify the CMSPages\PortalTemplate.aspx page. But this affects every page derived from it. I heavely relay on client side scripting (Jscript), and don't want to include all .js in every page.
I found this way:
1) in CMSPages\PortalTemplate.aspx add an ID to the <head> tag: <code> <head runat="server" id="Head"> </code>
2) in your WebPart configuration in the CODE tab add following: <code> <script runat="server"> protected override void OnLoad(EventArgs e) { base.OnLoad(e); HtmlContainerControl head = (HtmlContainerControl) Page.FindControl("Head"); if (null != head) { Literal lit = new Literal(); lit.Text = "<meta mymeta=mydata />"; head.Controls.Add(lit); } } </script> </code>
Now can i include my .js files only in those pages, with my WebParts on it.
What do you think about it? Is this "clean" enough? Is there an easyer way?
greetings Martin
|