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

SkinId in UserControl

1 Answer 172 Views
Menu
This is a migrated thread and some comments may be shown as answers.
lupotana
Top achievements
Rank 1
lupotana asked on 11 Jun 2010, 01:54 PM

Hi,
I want use a RadMenu in an UserControl.
I load dynamically the Menu Items in Page_Load Event and I want to set dynamically the SkinId of RadMenu.

If I set the SkinId in Page_Load I have this problem.
"The 'SkinId' property can only be set in or before the Page_PreInit event for static controls. For dynamic controls, set the property before adding it to the Controls collection."

But Usercontol don't have the Pre_Init event.

How do I set dynamically SkinId of my RadMenu ?

Thanks,
Marco

1 Answer, 1 is accepted

Sort by
0
Veronica
Telerik team
answered on 15 Jun 2010, 09:56 AM
Hi lupotana,

I've created a sample project to test your case. 

You need to set the SkinID of the Web User Control before adding it to the control collection:

protected void Page_Load(object sender, EventArgs e)
    {
        var userControl = Page.LoadControl("RadMenu.ascx");
        userControl.FindControl("RadMenu1").SkinID = "Office";
        Form.Controls.Add(userControl);
    }

Find the full code in the attached .zip file.

Hope this helps.

All the best,
Veronica Milcheva
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Menu
Asked by
lupotana
Top achievements
Rank 1
Answers by
Veronica
Telerik team
Share this question
or