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

Forums / General Discussions / Multiple ContentPlaceHolder or multiple generic content

Multiple ContentPlaceHolder or multiple generic content

8 posts, 0 answered
  1. vivek garg
    vivek garg avatar
    13 posts
    Registered:
    20 Aug 2009
    25 Aug 2009
    Link to this post
    Hi,

    I am referring exisitng thread to answer the question.

    How can I add Multiple ContentPlaceHolder or multiple generic content in sitefinity through page or template.

    http://www.sitefinity.com/support/forums/sitefinity-3-x/developing-with-sitefinity/how-to-dynamically-add-one-or-more-generic-content.aspx

    To more clarify is, this problem is related to giving flexibility so that site admin can add many section like many pods, one way can be using seperate contentplaceholder. Not sure if that is possible technically.

    Any support on this would highly appreciated.

    Thanks,
    Vivek

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    25 Aug 2009
    Link to this post
    Hello vivek garg,

    Adding GenericContent control is basically drag and drop from the toolbox to a ContentPlace holder. Each ContentPlaceHolder is adjustable so that you can add many GenericContent controls. Another option is creating a predefined pages - How to create predefined template pages that contain controls placed on the content areas

    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. vivek garg
    vivek garg avatar
    13 posts
    Registered:
    20 Aug 2009
    25 Aug 2009
    Link to this post
    Hi Ivan,

    Thanks for the reply but I have used in that way which you described but my requirement is different.
    Requirement is admin want flexibility so that they can add another control (Generic Content) but that should be in the same contentplace holder and size should be modifiable.

    If I can add multiple content place holder dynamically in the sitefinity page, Its just drag and drop.

    Now question is how can one dynamically add multiple content placeholder.

    Please suggtest the approach.

    Regards,
    Vivek
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    25 Aug 2009
    Link to this post
    Hello vivek garg,

    You can add the following logic to the code behind of your master file or in a user control.

    HtmlGenericControl control = Page.Master.FindControl("divID"as HtmlGenericControl; 
    ContentPlaceHolder holder = new ContentPlaceHolder(); 
    holder.ID = "NewID"
     control.Controls.Add(holder) 

    We will use RadDocks form version 4.0 which will make Page Edit mode more flexible.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. vivek garg
    vivek garg avatar
    13 posts
    Registered:
    20 Aug 2009
    26 Aug 2009
    Link to this post
    Thanks Ivan,

    This work fine as far as .net page goes but for sitefinity,  I am able to add multiple contentplaceholder and content (.net server control inside place holder) using code, but it is not editable in sitefinity.

    What I am looking is that any non developer can add multiple placeholder and content without doing any sort of development using sitefinity admin features and sitefinity generic content control.
    And this should be editable, which is not possible as part of .net Page (External Page in sitefinity).


    I tried using user control but as usercontrol can't be directly part of master page (didn't use contentpage (contentplaceholder) ), Can't add placeholder to parent holder as parent place holder is not there in case of user control.

    What should be the way.

    Regards,
    Vivek

  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    26 Aug 2009
    Link to this post
    Hello vivek garg,

    It is not possible to add a ContentPlaceHoder to a page without coding. As suggested you can create  an user friendly user control that could create content place holders. Also "We will use RadDocks form version 4.0 which will make Page Edit mode more flexible."

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  7. vivek garg
    vivek garg avatar
    13 posts
    Registered:
    20 Aug 2009
    27 Aug 2009
    Link to this post
    Hi Ivan,

    I am dynamically able to create controls in .net (.net page) as well as using user control.

    Sample Code for User Control is below. This work fine as far as .net goes by directly running the code.
    and using user control as part of the .net page. but it didn't work in sitefinity as i previously also said.

    .Net we have parent container (form), and we can specify LoadComplete event on which we can add.

    What would be the parent container in case of User Control in sitefinity.

    protected void Page_Load(object sender, EventArgs e)  
        {  
            this.Page.LoadComplete += new EventHandler(Create);  
        }  
     
        protected void Create(object o, EventArgs e)  
        {  
        int Pods = Convert.ToInt32(ConfigurationManager.AppSettings["PodNos"]);  
            if (Pods > 0)  
            {  
                TextBox txt = new TextBox();  
                txt.ID = "Text1";  
                txt.Text = "This is part of ContentPlaceHolder1";  
                PlaceHolder1.Controls.Add(txt);  
     
                //RadEditor rd = new RadEditor();  
                PlaceHolder1.Controls.Add(RadEditor1);     
     
                PlaceHolder ph1 = new PlaceHolder();  
                ph1.ID = "ph1";  
                  
                TextBox txt1 = new TextBox();  
                txt1.ID = "Text2";  
                txt1.Text = "This is part of ContentPlaceHolder2";  
     
                this.Page.FindControl("form1").Controls.Add(ph1);  
     
     
                ph1.Controls.Add(RadEditor1);    
                ph1.Controls.Add(txt1);     
            }  
        } 
    On which page event I can add controls. Please clarify.

     

     

     

     

     

     

    Regards,
    Vivek

     

     

     

     

     

  8. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    28 Aug 2009
    Link to this post
    Hi vivek garg,

    I see what you mean.

    The pages in Sitefinity are a little different than the native Asp.Net pages. Although they could be casted at some stage to Asp.Net IPage, they are CmsPages. I am sending you a code, which will represent how you can create a new page, and add a few controls to it. Since the controls should be persisted together with their properties, it is not just adding a control to the collection:

                CmsManager manager = new CmsManager(); 
     
                // Get some page template ID 
                Guid templateId = ((IPageTemplate)manager.GetTemplates()[0]).ID; 
     
                ICmsPage page = manager.CreatePage(this.TextBox1.Text); 
                page.Navigable = true
                page.MenuName = this.TextBox1.Text; 
                //page.ParentID = locationsPage.ID; 
                page.Title = this.TextBox1.Text; 
     
                //We can skip checkout on creating the page 
                //but it is recommended in order to comply with the lifecycle 
                IStagedPage staged = page.Staged.CheckOut(); 
                staged.SetTemplate(templateId, null); 
     
                LiteralControl lit = new LiteralControl(); 
                lit.Text = "<h1>This is test control</h1><br>"
                staged.AddControl("Content", lit); 
     
                //**** We need to get the page one more time in order to be JOINED to a transacton :) 
                //Note, the page is retrieved from the thread cache 
                page = (ICmsPage)manager.GetPage(page.ID, true); 
                LiteralControl lit2 = new LiteralControl(); 
                lit2.Text = "<h2>This is test control 2</h2><br>"
                staged.AddControl("Content", lit2); 
     
                page = (ICmsPage)manager.GetPage(page.ID, true); 
                staged.CheckIn(); 
     
                page.Publish(); 
            } 

    Note how the page should be taken for edit, check-out, checked in and published. This is needed so we can store a new version of the page each time you modify it. 

    Of course you can add controls just like in Asp.Net, but this will happen in the runtime only and will not be persisted after a postback/redirect. 

    I hope this helps.

    Regards,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Register for webinar
8 posts, 0 answered