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

Forums / Designing with Sitefinity / Generic Content Advanced Tab - ID Property

Generic Content Advanced Tab - ID Property

2 posts, 0 answered
  1. Paul Dench
    Paul Dench avatar
    19 posts
    Registered:
    26 Oct 2009
    09 Feb 2010
    Link to this post
    Hi,

    We are looking to set up a series of sections that will be shown/hidden based on users clicking on different selections on the web site. We thought we would write the JavaScript, and call show and hide code to manipulate some generic content items we set up. We see the ID property on the advanced tab of the generic content property sheet, but that doesn't seem to be used for anything. Should this ID be part of the end HTML that is generated when the page is rendered? is there another way to identify generic content blocks so we can show/hide them?

    Thanks!
    Paul Dench
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    10 Feb 2010
    Link to this post
    Hello Paul Dench,

    There are two options

    1. Add div or panel around the ContentPlaceHolder and use them to hide the control.

    2. Search for the control on a page as shown below

    var Manager = new CmsManager();
    ICmsPage page = (ICmsPage)Manager.GetPage(pageID, true);
     
    if (page != null)
    {
        IStagedPage staged = p.Staged.CheckOut();
        foreach (ICmsWebControl c in staged.Controls)
        {
              if (control.ControlType == (typeof(GenericContent)))
               {
                  GenericContent cnt = (GenericContent)control.LoadControl();
                  if (cnt != null)
                  {
                      // do something..
                  }
               }
        }
    }

    You can get the control by ID or ClientID which are properties of control object. After you find the control you can hide it.

    All the best,
    Ivan Dimitrov
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
2 posts, 0 answered