Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Haris Krajina 1 post 21 karma points
    May 19, 2013 @ 14:11
    Haris Krajina
    0

    Viewing model properties inside Umbraco template

    This should be simple enough question but I am having problems with it, I am trying to enable disable sidebar in umbraco template based on Model's property.

        <%@ Master Language="C#" MasterPageFile="~/masterpages/Master.master" AutoEventWireup="true" %>
        <asp:content ContentPlaceHolderId="MainContent" runat="server">
        <umbraco:Macro runat="server" language="cshtml">
        @{
            boolean enableSidebar = Model.GetProperty("enableSidebar").Value;
        }
        <div class="container" style="margin-top:20px;">
            <div class="row">
                <div class="@(enableSidebar ? "span9" : "span12")">
                    <div class="default-content">
                        <!-- CONTENT -->
                        <asp:ContentPlaceHolder runat="server" ID="MainContent" />
                    </div>
                </div>
                @if (enableSidebar) { 
                    <div class="span3 box">
                        <div class="green-header-box"></div>
                        <div class="inline box-content"> 
                            <!-- SIDEBAR -->
                            <asp:ContentPlaceHolder runat="server" ID="SidebarContent" />
                        </div>
                    </div>
                }
            </div>
        </div>
        </umbraco:Macro>
        </asp:content>

    I am getting error that says I cannot use asp tags inside macro which is fine, but I do not know how to do I achieve same effect without using macro, can you please help me re-write this properly?

Please Sign in or register to post replies

Write your reply to:

Draft