Copied to clipboard

Flag this post as spam?

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


  • Juan Pablo Belli 1 post 21 karma points
    Nov 02, 2009 @ 19:55
    Juan Pablo Belli
    0

    Problem with umbraco:item and server code (umbraco:item is not rendered when server code is executed)

    Hello everyone... I tryed something like (but obviously failed):

     <% var hasRole = (System.Web.Security.Roles.GetRolesForUser().Any(item => item == "<umbraco:item field='PageName' runat='server'></umbraco:item>" )); %>

    but when the server code is executed the umbraco:item is not rendered, so I was wondering if there is some other way to get the item value before render

    I was wondering about doing something like...

     <% var hasRole = (System.Web.Security.Roles.GetRolesForUser().Any(item => item == Umbraco.GetItemValue("PageName") )); %>

     

    Here I found a workaround but is not I was expecting

      <% var pageName = this.Request.RawUrl.Replace(".aspx", "").Replace("/","");

            var hasRole = (System.Web.Security.Roles.GetRolesForUser().Any(item => item == pageName )); %>

  • Dirk De Grave 4537 posts 6006 karma points MVP 3x admin c-trib
    Nov 03, 2009 @ 08:51
    Dirk De Grave
    0

    Hi,

    Could you explain what you're trying to achieve? There might be an easier way to accomplish what you're after.

     

    Looking forward to your info.

     

    Cheers,

    /Dirk

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies