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

Forums / Developing with Sitefinity / Custom control ID on FRONT

Custom control ID on FRONT

4 posts, 0 answered
  1. ansar foolchand
    ansar foolchand avatar
    13 posts
    Registered:
    17 Feb 2010
    22 May 2010
    Link to this post
    Hi,

    When I add a custom control via the BO and I click on EDIT, in the query string i get a value "sfctrlid". I have used this value in my custom control and stored it in a table i have created. Hence on a page via the BO the user can drop the same control more than once.

    Now on the website (the front) when the controls are loading (let say the user added twice the same control) how I can get back this "sfctrlid" for each control for me to load the appropriate information?

    Regards,
    Ansar Foolchand
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    24 May 2010
    Link to this post
    Hello ansar foolchand,

    You should loop through the controls collection of the page and get the control. Then set the properties you want. Sample code is provided here - Modifying Controls

    All the best,
    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. ansar foolchand
    ansar foolchand avatar
    13 posts
    Registered:
    17 Feb 2010
    24 May 2010
    Link to this post
    Hi Ivan Dimitrov,

    Thank you for your quick reply. For info my company has already purchase a licence of sitefinity (esp due to the reactive support). I have already used the codes your referred to but it does not actually meet my need. I shall try to explain clearly what I really need:

    1.    I have a custom control name "ArticleList" and as its name suggest il provides a list of articles.
    2.    I have created a BackOffice where the user can create many articles and each article has a category.
    3.    In the "articlelist", when the user click on the EDIT button a popup appears with a dropdown where the user can select a category. Hence the "ArticleList" will only display articles (only title) for the specified category.
    4.    When the user click on the "I'm Done" button of the popup, I store the "PAGE ID", "Control ID (sfctrlid)" and the category chosen.
    5.    Now let say a user added twice the "ArticleList" control on a page, i will store two lines in my table, each will have the same "PAGE ID" but different "Control ID" and category.
    6.    Till here everything is working fine.
    7.    Now when i view the page "in LIVE mode", both controls are loaded. HOWEVER I AM UNABLE TO DIFFERENTIATE BETWEEN THE CONTROLS.
    8.    In the "ArticleList" on the page load method i have a function "BindArticles" which takes one parametre "Category". HOW CAN I KNOW IN THE "page_load" METHOD OF THE CONTROL THE "Control_id" OF THE INSTANCE OF THE CONTROL FOR ME TO RETRIEVE THE ASSOCIATED "Category".

    Thanking you in anticipation.

    Regards,
    Ansar Foolchand
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    24 May 2010
    Link to this post
    Hi ansar foolchand,

    The post that I sent you explains how to get access to the control properties and identify the control ID on the public side. 

    var cmsManager = new Telerik.Cms.CmsManager();
         var currentNode = (Telerik.Cms.Web.CmsSiteMapNode)SiteMap.CurrentNode;
         var currentPage = currentNode.CmsPage;
         IList<Telerik.Cms.ICmsWebControl> pageControls = currentPage.Staged.Controls;
         foreach (Telerik.Cms.ICmsWebControl webCtrl in pageControls)
         {
             //webCtrl.ID WILL RETURN YOU sfctrlid VALUE THAT HAS BEEN SET
             if (webCtrl.ContainerID == "IntroductoryContent" && webCtrl.ControlType == typeof(Telerik.Samples.WebControls.SomeControl))
             {
                 var cntrl = webCtrl.LoadControl() as Telerik.Samples.WebControls.SomeControl;
              
             }
         }

    If you have two instanced of the same type you should look for the control ID. The way that you will identify the ID is the same as you will use for each other ASP.NET web site-  you need to loop through the control collection and get the type of your control. You could find the control by its placeholder ID and then finding the control by ID.

    ContentPlaceHolder holder = this.Page.FindControl("Myholder") as ContentPlaceHolder;
            if (holder != null)
            {
                ArchiveList cntrl = holder.FindControl("ArchiveList1") as ArchiveList ;
                if (cntrl != null)
                {
                   //
                }
      
            }


    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.
Register for webinar
4 posts, 0 answered