Copied to clipboard

Flag this post as spam?

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


  • Adrian Alexa 50 posts 100 karma points
    Mar 02, 2012 @ 08:01
    Adrian Alexa
    0

    How to run a c# script in a template?

    Hi, as I am a newbie to umbraco i have the fallowing scenario: I have  a website with 4 pages. (the website address is www.hotelopro.com, in case you want to see it)

    If i am on features page I must add an extra css class to a link.

    Masterpage begins like this:

    <%@ Master Language="C#" MasterPageFile="~/umbraco/masterpages/default.master" AutoEventWireup="true" %>

    <asp:Content ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server">

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"[]>
      <!--[if IE 9 ]><html class="ie9" xmlns="http://www.w3.org/1999/xhtml"> <![endif]-->
      <!--[if (gt IE 9)|!(IE)]><!-->
      <html xmlns="http://www.w3.org/1999/xhtml">
        <!--<![endif]-->

        <head id="head" runat="server">
          <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
          <title>
            <umbraco:Item field="pageTitle" stripParagraph="true" runat="server" />
              <umbraco:item id="Item2" runat="server" field="siteName" recursive="true">
              </umbraco:item></asp:placeholder>
          </title>
          <umbraco:Item field="keywords" insertTextBefore="&lt;meta name=&quot;keywords&quot; content=&quot;" insertTextAfter="&quot; /&gt;" runat="server">
          </umbraco:Item>

     

    and then i have the menu:

    <div id="menu">
                <table cellpadding="0" cellspacing="0">
                  <tbody>
                    <tr>
                      <td>
                      <a !Here insert a class! href="/features-ro.aspx">
                      <umbraco:Item field="#Features" runat="server" />
                      </a>
    If current page selected is features then I must say: <a class="active_page" ....

    How can I do this?

    Thanks.        

  • Rich Green 2246 posts 4008 karma points
    Mar 02, 2012 @ 09:00
    Rich Green
    0

    I would create a Macro with your logic in either XSLT or Razor, whichever you prefer.

    Rich

  • Adrian Alexa 50 posts 100 karma points
    Mar 02, 2012 @ 13:49
    Adrian Alexa
    0

    can you please provide me some examples or something? i haven't yet created any xslt. I see that xslt is only for output html code ...(which then i don't see the reason why should I use it) ( i read this: http://blog.percipientstudios.com/2009/4/11/anatomy-of-an-umbraco-xslt-file.aspx )

    i have only used macros (usercontrollers made in c#)

  • Adrian Alexa 50 posts 100 karma points
    Mar 02, 2012 @ 14:27
    Adrian Alexa
    0

    thanks in advance...

    however in the meaning time I created a web user controler which sets a Litteral to 'class="active_page"' case when the view name is the same as a parameter sent by me. 

    So problem solved.

    thanks.

Please Sign in or register to post replies

Write your reply to:

Draft