Sitefinity CMS

Wrap RadRotator in a User Control Send comments on this topic.
How-to > Controls > RadControls for ASP.NET AJAX > Wrap RadRotator in a User Control

Glossary Item Box

At some events, new pages need to be created. One example for this is to implement a calendar so that for each new event a separate page to appear. There is an easier way to achieve this apart from waiting for the event to occur and then creating a new page for it. 

 

The following code shows how to set a module to create a page programmatically at a specific event, add the event control to that page, set both the template and theme of that page:

CreateUserPage() Copy Code
private void CreateUserPage(string userName, string firstName, out Guid pageId)   
{   
 
// creates user's page   
 
CmsManager manager = new CmsManager();   
 ICmsPage userPage = manager.CreatePage(userName);   
 pageId = userPage.ID;   
 userPage.Navigable = true;   
 userPage.MenuName = firstName;   
 
 manager.SavePage(userPage);   
 userPage = (ICmsPage)manager.GetPage(userPage.ID, true);   
 
 Label lbl =
new Label();   
 lbl.ID =
"Label1";   
 lbl.Text =
"My Label";   
 
 IStagedPage stage = userPage.Staged.CheckOut();   
 
 
// adds Label control to the page in a container with ID Content   
 
stage.AddControl("Content", lbl);   
 userPage = (ICmsPage)manager.GetPage(userPage.ID, true);   
 
 
// gets template with a name "default" and after that sets it for the newly created page   
 
IPageTemplate template = manager.GetTemplate("default");   
 userPage.Staged.SetTemplate(
template.ID, "Blue with right sidebar");   
 
 userPage = (ICmsPage)manager.GetPage(userPage.ID, true);   
 userPage.Stage.CheckIn();   
}    

 

ICmsPage object needs to be retrieved after each operation because the methods AddControl and SetTemplate commit the current transaction automatically.