Copied to clipboard

Flag this post as spam?

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


  • Vineet Kothari 32 posts 53 karma points
    Apr 12, 2010 @ 10:29
    Vineet Kothari
    0

    Retrieving member nodeId after login

    I am building a small invitation portal allowing member to create event & send others invitation for the event.

    I am using osMemberControls for login, logout, member registration as well as member profile. But since a member's event will be associated to his nodeID (I am creating my own table in order to store the details of event into the database). How will I extract a members id after he logs in. Umbraco does not pass query strings, I dont know what other way is used either session or cookie.

    I am not a programmer so I dont know how to do it. can anyone help me how I can extract member info in my user control so that I can use it to display the events created by him.

    Thanks
    Vineet

  • Vineet Kothari 32 posts 53 karma points
    Apr 13, 2010 @ 20:08
    Vineet Kothari
    0

    *bump*

  • Kevin Farrow 46 posts 67 karma points
    Apr 13, 2010 @ 20:59
    Kevin Farrow
    0

    have you tried...

    string memberGuid = HttpContext.Current.Request.Cookies["umbracoMemberGuid"].Value;
    umbraco.cms.businesslogic.member.Member member = new Member(new guid(memberGuid));

    int memberId = member.Id;

     

    Regards,
    Kevin Farrow
    http://www.RevisionSoftware.com

  • Vineet Kothari 32 posts 53 karma points
    Apr 14, 2010 @ 05:50
    Vineet Kothari
    0

    Kevin I tried what you suggested btu I received this error:

    Object reference not set to an instance of an object.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

    Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.


    What I did was just used your code & tried to print that ID by click on a button. I referenced & used using umbraco.cms.businesslogic.member;
    using umbraco.cms;
    & this is my code. Nothing fancy just a simple click button.

     protected void Button1_Click(object sender, EventArgs e)
            {
                string memberGuid = HttpContext.Current.Request.Cookies["umbracoMemberGuid"].Value;
                umbraco.cms.businesslogic.member.Member member = new Member(new Guid(memberGuid));
                int memberId = member.Id;
                TextBox1.Text = memberId.ToString();
            }


    Can you point me where I am making a mistake.

  • skiltz 501 posts 701 karma points
    Apr 14, 2010 @ 07:12
    skiltz
    0

    Think you can get current member using

    umbraco.cms.businesslogic.member.Member.GetCurrentMember().Id

  • Vineet Kothari 32 posts 53 karma points
    Apr 14, 2010 @ 08:18
    Vineet Kothari
    0

    skiltz, I think I am getting things wrong can you let me know how can I store the value of memberID of currently logged in member & do let me know what umbraco libraries are to be referenced in the user control.

    I apolgize for asking too much but can you give me a simple code that takes the memberID & displays it as a label or literal

  • Vineet Kothari 32 posts 53 karma points
    Apr 14, 2010 @ 10:07
    Vineet Kothari
    0

    skiltz,

    I even tried this code you specified in this fashion:

    int memberID = umbraco.cms.businesslogic.member.Member.GetCurrentMember().Id;
    Label1.Text = memberID.ToString();

    So there something I am doing wrong since I am getting the same error which I think is because its getting null value.

    Object reference not set to an instance of an object.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

    Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

    To make sure there is a member logged in I do login as a member first before going to the content oage where I have this user control embedded.

  • skiltz 501 posts 701 karma points
    Apr 14, 2010 @ 22:40
    skiltz
    0

    Have you uploaded your .ascx page as well???  To get the members name you would normally use Label1.Text = User.Identity.Name;

     

  • Vineet Kothari 32 posts 53 karma points
    Apr 15, 2010 @ 01:01
    Vineet Kothari
    0

    yes I did uploaded the .ascx page to /usercontrols folder & made macro out of it.

    I wanted to get the currently logged in member's nodeId & may be try ot print it as a label or inside a textbox should also work I just need to get an idea about how to store it in a variable so I can pass it if required

  • Kevin Farrow 46 posts 67 karma points
    Apr 15, 2010 @ 21:00
    Kevin Farrow
    0

    Have you also copied your dll to the /bin folder?

    Regards,
    Kevin

  • Vineet Kothari 32 posts 53 karma points
    Apr 15, 2010 @ 22:39
    Vineet Kothari
    0

    Yes Kevin, I did that. I copied .dll to /bin folder & .ascx file to the /usercontrol folder.

    I would appreciate if you have the code to show memberID (nodeId imean) it can be via label, literal or textbox on any button click or anyways than can you please pass me on the solution. I am this will take just 5-10 mins at the max to you guys to make that solution but this will surely help me alot in my project.

    I am really confused about how to get this thing working.

  • Vineet Kothari 32 posts 53 karma points
    Apr 16, 2010 @ 19:12
    Vineet Kothari
    0

    *bump*

  • Kevin Farrow 46 posts 67 karma points
    Apr 17, 2010 @ 00:13
    Kevin Farrow
    0

    Could you email me your code, or the part of the code that is causing the error to kevin_farrow (at) yahoo.com and I should be able to help.

  • Vineet Kothari 32 posts 53 karma points
    Apr 17, 2010 @ 22:00
    Vineet Kothari
    0

    I emailed you last night kevin, eagerly waiting for your response :)

  • Vineet Kothari 32 posts 53 karma points
    Apr 18, 2010 @ 02:21
    Vineet Kothari
    0

    anybody would like to suggest something on this issue?

  • Nik Wahlberg 639 posts 1237 karma points MVP
    Apr 18, 2010 @ 02:38
    Nik Wahlberg
    0

    Vineet, I have not worked with osMemberControls but there is no reason you shouldn't be able to tap into the following:

    Test.aspx

    <asp:Label ID="_memberId" runat="server"></asp:Label>

    Test.apsx.cs

    umbraco.cms.businesslogic.member.Member m = umbraco.cms.businesslogic.member.Member.GetCurrentMember();
    _memberId.Text = m.Id.ToString();

    If this is throwing errors for you then you're defiitely missing needed libraries in your bin folder (Umbraco core libraries). 

    HTH.
    Nik

  • Vineet Kothari 32 posts 53 karma points
    Apr 18, 2010 @ 09:36
    Vineet Kothari
    0

    Hey Thnx Nik this worked... :D

  • Nik Wahlberg 639 posts 1237 karma points MVP
    Apr 18, 2010 @ 14:47
    Nik Wahlberg
    0

    Sure, please mark the topic as solved.

    Thanks,
    Nik

Please Sign in or register to post replies

Write your reply to:

Draft