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.
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(); }
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
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.
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
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.
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
*bump*
have you tried...
Regards,
Kevin Farrow
http://www.RevisionSoftware.com
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.
Think you can get current member using
umbraco.cms.businesslogic.member.Member.GetCurrentMember().Id
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
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.
Have you uploaded your .ascx page as well??? To get the members name you would normally use Label1.Text = User.Identity.Name;
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
Have you also copied your dll to the /bin folder?
Regards,
Kevin
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.
*bump*
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.
I emailed you last night kevin, eagerly waiting for your response :)
anybody would like to suggest something on this issue?
Vineet, I have not worked with osMemberControls but there is no reason you shouldn't be able to tap into the following:
Test.aspx
Test.apsx.cs
If this is throwing errors for you then you're defiitely missing needed libraries in your bin folder (Umbraco core libraries).
HTH.
Nik
Hey Thnx Nik this worked... :D
Sure, please mark the topic as solved.
Thanks,
Nik
is working on a reply...