Copied to clipboard

Flag this post as spam?

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


  • Ashkan Taravati 17 posts 37 karma points
    May 06, 2014 @ 17:07
    Ashkan Taravati
    0

    login Status

    Hi how do I code for a razor conditional statement to check whether a member i logged in or not and do separate things for each condition.i tried searching the net and our umbraco but everything i tested returned a runtime error. Thanks

  • Desley 44 posts 169 karma points
    May 06, 2014 @ 17:26
    Desley
    0

    Might be better ways but this should work atleast.

    var currentMember = umbraco.cms.businesslogic.member.Member.GetCurrentMember();
    
    if (currentMember != null) {..}
    
  • Ashkan Taravati 17 posts 37 karma points
    May 06, 2014 @ 17:42
    Ashkan Taravati
    0

    still runtime error am i doing it wrong?

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage @{ var currentMember = umbraco.cms.businesslogic.member.Member.GetCurrentMember(); @if (currentMember != null) {

    "مهمان"

    }
    @else{
        <p id="statusmsg"> "!وقت بخیر،" @currentMember.name </p> 
    }
    

    }

  • Ashkan Taravati 17 posts 37 karma points
    May 06, 2014 @ 18:01
    Ashkan Taravati
    0

    can't i use something like isloggedon?

  • Desley 44 posts 169 karma points
    May 08, 2014 @ 13:26
    Desley
    0
    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage 
    @{ var currentMember = umbraco.cms.businesslogic.member.Member.GetCurrentMember(); 
    
    @if (currentMember != null) {
      //This is where the member is logged in
      <p id="statusmsg">Welcome @currentMember.LoginName </p> 
    }
    else{
      //This is where the member is NOT logged in
      <p id="statusmsg">Please log in</p>        
    }
    }
    
  • Ashkan Taravati 17 posts 37 karma points
    May 08, 2014 @ 13:31
    Ashkan Taravati
    0

    Thanks desley But the problem is that the code makes the site show runtime error. I first wrote it with Membership.GetUser with no conditional logics but as soon as i change it to conditional it returns runtime error!

  • Desley 44 posts 169 karma points
    May 08, 2014 @ 13:37
    Desley
    0

    You were trying to get a property from the member object when it was null. Try the code above, it works fine when I try it myself.

    If it still doesn't work I can't help you any further. My programming knowledge is very limited too.

  • Ashkan Taravati 17 posts 37 karma points
    May 08, 2014 @ 13:40
    Ashkan Taravati
    0

    I know i had corrected it before ;) Thanks anyway I found nothing helping on the net

Please Sign in or register to post replies

Write your reply to:

Draft