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

Forums / Designing with Sitefinity / If statement in ASP.net

If statement in ASP.net

6 posts, 0 answered
  1. Damir
    Damir avatar
    22 posts
    Registered:
    24 Nov 2008
    02 Oct 2009
    Link to this post
    I have this code that shows a summary of news on details news page

     <div class="NewsFullSummary"
            <asp:Literal ID="Summary" runat="server"></asp:Literal> 
        </div> 

    when i hide the summary in admin i only get the div to show without the summary but there is a style on that div and i would like to hide it when summary is hidden is there a way to hide a div with if statement if that exists in asp.net

    like:

    if summary = true
    then show code above
    if not show nothing




  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    03 Oct 2009
    Link to this post
    Hi Damir,

    You can add id and runat attributes to the div. Then you will be able to access it a hide it using Visible property. Another option could be using Panel control.

    Sincerely yours,
    Ivan Dimitrov
    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.
  3. Damir
    Damir avatar
    22 posts
    Registered:
    24 Nov 2008
    06 Oct 2009
    Link to this post
    You can add id and runat attributes to the div. Then you will be able to access it a hide it using Visible property.

    Can you please give me an example for this?
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    06 Oct 2009
    Link to this post
    Hi Damir,

    Below is shown sample code:

      <div class="NewsFullSummary" id="sum" runat="server">  
            <asp:Literal ID="Summary" runat="server"></asp:Literal> 
        </div>  

    public void Page_Load(object sender, EventArgs e) 
        { 
            this.sum.Visible = true
        } 

    You need to add if loop to check whether this div should be visible or not.

    Best wishes,
    Ivan Dimitrov
    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.
  5. Damir
    Damir avatar
    22 posts
    Registered:
    24 Nov 2008
    06 Oct 2009
    Link to this post
    I am using custom control templates for the News Control.
    News control has a "News Setting" to show or hide the Summary.

    When the summary is hidden, the
    <asp:Literal ID="Summary" runat="server"></asp:Literal> 
    is also hidden, how can I now through some API call also hide the surrounding DIV element?

    Is it possible to identify each News Control's property to check if Summary is shown?
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    06 Oct 2009
    Link to this post
    Hi Damir,

    You can map NewsViewControlDesigner template and add new TextSetting control for the div.

    Sample:

    <sfDesignSettings:TextSetting ID="CustomTextSetting" 
                 TargetID="Summary" 
                 SettingTitle="DIVID" 
                 AllowLabelSetting="false" 
                 AllowFormatSetting="false" 
                 AllowVisibilitySetting="True" 
                 TargetVisibleByDefault="True"
    </sfDesignSettings:TextSetting> 


    Kind regards,
    Ivan Dimitrov
    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
6 posts, 0 answered