Add confirmation to the title from the control

When loading a page of an A Page.Header control, it is null when I try to add a link. Is there anything special I have to do to add a link to the page head using a control.

Maybe the best way this happens when loading Page.Header or when it can be accessed from a control

+6
c # controls
source share
2 answers

Be sure to set your header tag runat = "server"

<head runat="server"> .. </head> 

otherwise, the link to Page.Header will always be null.

+16
source share

You can simply add an event handler to the Loaded Event page inside the Load Event control and do what you want.

Something like that:

  this.Page.LoadComplete += (ObjectSender, ev) => { var mStyle = new Style(); mStyle.BorderWidth = new Unit(5); Page.Header.StyleSheet.CreateStyleRule(mStyle, null, "body"); }; 

ps. I used the lambda expression for simplicity.

+1
source share

All Articles