+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / How to place user control to content place holder programmatically?

How to place user control to content place holder programmatically?

5 posts, 0 answered
  1. Björn
    Björn avatar
    11 posts
    Registered:
    29 Nov 2007
    02 Jan 2011
    Link to this post
    How to place user control to content place holder programmatically. I made user A and uploaded to sitefinity. I do not want this user control ‘A’ to put in content place holder by dragging and dropping. I want to place it through program or sitefinity  api. How can we do this? Please provide me some example and step by step procedure. please see the attachment.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    03 Jan 2011
    Link to this post
    Hello Björn,

    Please check this KB article - How to create predefined template pages that contain controls placed on the content areas

    Regards,
    Ivan Dimitrov
    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
  3. humayoo
    humayoo avatar
    89 posts
    Registered:
    25 Oct 2010
    03 Jan 2011
    Link to this post
    Hi,

    i read the reference given by you. my requirement is like this.

    1. there is master template.suppose name of this master template is A. this master template contain content placeholder  placeholder1,placeholder2 and placeholder3.

    2. i have following user controls uploaded to my project from admin side. usercontrol1,usercontrol2,usercontrol3,usercontrol4,usercontrol5,usercontrol6

    3. when admin user create the new page, and select the master template 'A'. then usercontrol2,usercontrol4 and user control6 automatically placed into master template A placeholder placeholder1,placeholder2 and placeholder3 respectively.

    i hope that you understand my requirement. how do we do this (above requirement)? please provide me some example and step by step procedure.

    thanks
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    03 Jan 2011
    Link to this post
    Hi humayoo,

    Below is a sample code that illustrates how to access the DropDownList control in PageEdit mode

    public class EditPageCustom : EditPage
    {
       
       
        // override CreateChildControls method.
        protected override void CreateChildControls()
        {
            base.CreateChildControls();
       
            //Find the toolbar control
            ToolBar toolbar = this.Form.FindControl("toolbar") as ToolBar;
            // find the container where themes DropDownList control is located
            // here you can use recursion as well.
            Control cntr = toolbar.Controls[0].Controls[0];
            cntr = cntr.Controls[cntr.Controls.Count - 1];
            cntr = cntr.Controls[cntr.Controls.Count - 1];
            cntr = cntr.Controls[cntr.Controls.Count - 1];
            // check whether there is container and toolbar control.
            if (cntr != null && toolbar != null)
            {
                // find the DropDownList control
                 DropDownList ddList = cntr.FindControl("themes") as DropDownList;
                   // loop through the list items
                    foreach (ListItem item in ddList.Items)
                    {    
                        // do something here or manage ddList control
                    }
             }
         }
       
    }
     

    Modify EditPage.aspx located under Sitefinity/Admin folder.
    <%@ Page Inherits="EditPageCustom, App_Code" MasterPageFile="~/Sitefinity/Dummy.master" %>
     
    Then you have to subscribe for SelectedIndexChanged event and add the controls on a page.


    Regards,
    Ivan Dimitrov
    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
  5. humayoo
    humayoo avatar
    89 posts
    Registered:
    25 Oct 2010
    04 Jan 2011
    Link to this post
    hi,

    i think that you did not get my question clearly. i went through the following link http://www.sitefinity.com/devnet/kb/sitefinity-3-x/how-to-create-predefined-template-pages-that-contain-controls-placed-on-the-content-areas.aspx given by you. in this article there is explanation like "The way to enhance this approach could be to define XML file to map parent pages, templates, containers and controls so to give a simpler way of predefining pages".

    i want to place user controls in page content placeholder pro grammatically using XML approach.

    thanks
Register for webinar
5 posts, 0 answered