Copied to clipboard

Flag this post as spam?

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


  • TaoistTotty 246 posts 314 karma points
    Feb 26, 2012 @ 15:37
    TaoistTotty
    0

    What is wrong with this Razor Script?

    I am try to use the following razor script and it does not work with the following error.

    
    @inherits umbraco.MacroEngines.DynamicNodeContext
    @if(@Model.showTopBorders != false)
    {
     if(@Model._websitePicker = 168)
     {
      <img src="/media/123/top_bar.jpg" atl="Top Grey Image" />
      <img src='@Model.Media("topImage", "umbracoFile")' />
      <img src="/media/53/bottom_bar.jpg" alt="Bottom Grey Bar" />
      }else
     {
      <img src="/media/123/top_bar.jpg" alt="Top Grey Image" />
      <img src='@Model.Media("topImage", "umbracoFile")' />
      <img src="/media/53/bottom_bar.jpg" alt="Bottom Grey Image" />
      }
     }else
    {
     <img src='@Model.Media("topImage", "umbracoFile")' />
     }

    The error is:

     

    Error Loading Razor Script (file: Top Image2) 'umbraco.MacroEngines.DynamicNode' does not contain a definition for '_websitePicker' at CallSite.Target(Closure , CallSite , Object , Int32 )

    at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)

      at ASP._Page_macroScripts_TopImage2_cshtml.Execute() in \\TopImage2.cshtml:line 4

    at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()

    at System.Web.WebPages.WebPage.ExecutePageHierarchy()

    at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)

    at umbraco.MacroEngines.RazorMacroEngine.ExecuteRazor(MacroModel macro, INode currentPage)

    at umbraco.MacroEngines.RazorMacroEngine.Execute(MacroModel macro, INode currentPage)

     

    Many thanks

    TT

  • Douglas Ludlow 210 posts 366 karma points
    Feb 26, 2012 @ 16:25
    Douglas Ludlow
    1

    Looks like you're accidentally making an assignment to Model._websitePicker instead of checking for equality. It should be:

    if(Model._websitePicker == 168)
     {...}
  • TaoistTotty 246 posts 314 karma points
    Feb 26, 2012 @ 18:29
    TaoistTotty
    0

    Many thanks Douglas that was it.

Please Sign in or register to post replies

Write your reply to:

Draft