This is a migrated thread and some comments may be shown as answers.

Is it possible to create a "RadStyleSheetManager" at the runtime in code behind ?

4 Answers 128 Views
ScriptManager and StyleSheetManager
This is a migrated thread and some comments may be shown as answers.
ba
Top achievements
Rank 1
ba asked on 13 Sep 2011, 06:39 PM
Is it possible to create a <RadStyleSheetManager> control programmatically just with a code behind in the cs class ? In other words, without declare something in the aspx page ? And if yes is it possible to put it in a content place of a master page if the page is linked to a master page ? tx and regards for your help.

4 Answers, 1 is accepted

Sort by
0
Simon
Telerik team
answered on 14 Sep 2011, 02:39 PM
Hi Ba,

You can use the following code (used on a normal page):
override void OnInit(EventArgs e) {
// Every page should have a script manager and style sheet manager
    if (Page.Form != null) {
        if (RadStyleSheetManager.GetCurrent(Page) == null) {
            RadStyleSheetManager styleSheetManager = new RadStyleSheetManager();
            //styleSheetManager.StyleSheets.Add(new StyleSheetReference(""));
 
            Page.Form.Controls.AddAt(0, styleSheetManager);
         }
    }   
    base.OnInit(e);
}

The only requirement for this to work in Master/Content page setups is that the control must be added in the Form.

I hope this helps.

Regards,
Simon
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal
0
ba
Top achievements
Rank 1
answered on 14 Sep 2011, 03:06 PM
Thanks Simon,
It's running perfect.
0
Somnath
Top achievements
Rank 1
answered on 15 Sep 2011, 10:47 AM
Hi  Simon,

I am following the same approch to create a RadStyleSheetManager in code behind.
But here I am adding the control in Header and it is working perfect. 

Page.Header.Controls.Add(objStyleSheetManager);

We are having the Master/Content page in application and the same code is working for them as well.

My question is then why it is required to add RadStyleSheetManager control in Form.

Thanks n Regards,
0
Simon
Telerik team
answered on 20 Sep 2011, 11:11 AM
Hi Ankit,

Actually it can also be added in the <head>. The 'requirement' I mentioned was more of a convention rather than a real requirement. Please excuse me for misleading you.

Best wishes,
Simon
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
ScriptManager and StyleSheetManager
Asked by
ba
Top achievements
Rank 1
Answers by
Simon
Telerik team
ba
Top achievements
Rank 1
Somnath
Top achievements
Rank 1
Share this question
or