Copied to clipboard

Flag this post as spam?

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


  • FarmFreshCode 225 posts 422 karma points
    Jun 21, 2011 @ 20:06
    FarmFreshCode
    0

    Single Selection List Items - If Statement Format for .cshtml file

    Hello Everyone! I'm using v4.7..

    I am trying to allow my users to link a (Location & Link to a Map) to each individual blog post. I am using uBlogsy and am trying to update the (uBlogsyShowPost.cshtml) file.

    I have created a dataType called Locations as you can see below.

    Now below I have kind of a sample of code that expresses how I would like to have it. Where I create a varible from my dataType (uBlogsylocationPicker) and if the value is equal to 64 then it displays name of the building as well as a customized link for that specific building.

      @{ if (Model.NodeTypeAlias == "uBlogsyPost"){ 
    var uBlogsyLocate = @d.GetProperty("uBlogsylocationPicker");

    if (uBlogsyLocate == "64")
    {
    <text>Map Location: </text><a href="/link/64">@uBlogsyLocate</a>
    }
    if (uBlogsyLocate == "65")
    {
    <text>Map Location: </text><a href="/link/65">@uBlogsyLocate</a>
    }
    else { }
    }
    }

    However this doesn't work. I always get an error that says..

    [....Operator '==' cannot be applied to operands of type 'umbraco.interfaces.IProperty' and 'string']

    How can I make this happen? is there a better way?
    Thanks in advance for your help!

  • Brian Manning 22 posts 43 karma points
    Jun 21, 2011 @ 20:17
    Brian Manning
    1

    I haven't done this myself, but it looks like you could try:

    if(uBlogsyLocate.ToString() =="64")

    to get you where you want. I would surmise that ToString() for IProperty will return the value of that property.

  • FarmFreshCode 225 posts 422 karma points
    Jun 21, 2011 @ 20:22
    FarmFreshCode
    0

    Nice, thanks Brian.. I had to change it to this:

    if(uBlogsyLocate.ToString()=="Student Union")

    instead of the numeric value.. but thats fine with me.

Please Sign in or register to post replies

Write your reply to:

Draft