Click here to Skip to main content
15,567,466 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to write Context menu helper class Pin
Eddy Vluggen27-Aug-14 9:12
professionalEddy Vluggen27-Aug-14 9:12 
Questionc# XML nodelist to datagrid Pin
jdpiper6526-Aug-14 12:44
jdpiper6526-Aug-14 12:44 
AnswerRe: c# XML nodelist to datagrid Pin
Bernhard Hiller26-Aug-14 21:55
Bernhard Hiller26-Aug-14 21:55 
GeneralRe: c# XML nodelist to datagrid Pin
jdpiper6527-Aug-14 5:58
jdpiper6527-Aug-14 5:58 
Questionscraping C# Pin
jojoba2026-Aug-14 11:23
jojoba2026-Aug-14 11:23 
AnswerRe: scraping C# Pin
Dave Kreskowiak26-Aug-14 13:13
mveDave Kreskowiak26-Aug-14 13:13 
SuggestionRe: scraping C# Pin
jojoba2027-Aug-14 7:59
jojoba2027-Aug-14 7:59 
QuestionObject Reference Error Pin
Member 914293626-Aug-14 8:29
Member 914293626-Aug-14 8:29 
Hi All,

Can anyone help, I am getting an object reference error in my code. All I am doing is adding two tables to one table, the tables that are being added are Genealogy Table and Relationship Table to Details Table.

The error is below:

An object reference is required for the non-static field, method, or property 'MvcGenealogy.Models.GRHolding.GetDetailID(System.Web.HttpContextBase)'

The error is part of a holding model, the code that is causing the error is below:

C#
public static GRHolding GetDetail(HttpContextBase context)
        {
            var detail = new GRHolding();
            detail.GRHoldingID = GRHolding.GetDetailID(context);
            return detail;
        }

It references the GetDetailID, the code is below and come from the same Model.GRHolding:

C#
public string GetDetailID(HttpContextBase context)
        {
            if (context.Session[DetailsSessionKey] == null)
            {
                if (!string.IsNullOrWhiteSpace(context.User.Identity.Name))
                {
                    context.Session[DetailsSessionKey] = context.User.Identity.Name;
                }
                else
                {
                // Generate a new random GUID using System.Guid class
                    Guid tempDetailsID = Guid.NewGuid();
                    // Send tempDetailsID back to client as a cookie
                    context.Session[DetailsSessionKey] = tempDetailsID.ToString();
                }
            }
            return context.Session[DetailsSessionKey].ToString();
        }

I do have a Session in my Model call DetailsSessionKey which is a string and identifies with the DetailsID. The code that declares this is here:

C#
public const string DetailsSessionKey = "DetailsID";


I think the problem is in my session because the error is with this line of code "detail.GRHoldingID = GRHolding.GetDetailID(context);", which under the GetDetail in my GRHolding.cs model. It is not converting it to a string properly. I think it is something minor in the session, can anyone help? All I am to doing is associating two tables, (Genealogy table and Relationship table), with one table, (Details table).
AnswerRe: Object Reference Error Pin
OriginalGriff26-Aug-14 9:17
mvaOriginalGriff26-Aug-14 9:17 
GeneralRe: Object Reference Error Pin
Member 914293626-Aug-14 20:17
Member 914293626-Aug-14 20:17 
AnswerRe: Object Reference Error Pin
Richard Deeming26-Aug-14 10:21
mveRichard Deeming26-Aug-14 10:21 
GeneralRe: Object Reference Error Pin
Member 914293626-Aug-14 20:02
Member 914293626-Aug-14 20:02 
GeneralRe: Object Reference Error Pin
Bernhard Hiller26-Aug-14 22:05
Bernhard Hiller26-Aug-14 22:05 
QuestionSpeech recogination of specific language Pin
frech8726-Aug-14 2:16
frech8726-Aug-14 2:16 
AnswerRe: Speech recogination of specific language Pin
Pete O'Hanlon26-Aug-14 2:44
mvaPete O'Hanlon26-Aug-14 2:44 
GeneralRe: Speech recogination of specific language Pin
frech8726-Aug-14 2:48
frech8726-Aug-14 2:48 
GeneralRe: Speech recogination of specific language Pin
ZurdoDev26-Aug-14 2:56
professionalZurdoDev26-Aug-14 2:56 
GeneralRe: Speech recogination of specific language Pin
GuyThiebaut26-Aug-14 4:40
professionalGuyThiebaut26-Aug-14 4:40 
GeneralRe: Speech recogination of specific language Pin
Pete O'Hanlon26-Aug-14 4:55
mvaPete O'Hanlon26-Aug-14 4:55 
GeneralRe: Speech recogination of specific language Pin
GuyThiebaut26-Aug-14 5:05
professionalGuyThiebaut26-Aug-14 5:05 
GeneralOT Pin
Keith Barrow26-Aug-14 5:34
professionalKeith Barrow26-Aug-14 5:34 
GeneralRe: OT Pin
Chris Quinn26-Aug-14 6:09
Chris Quinn26-Aug-14 6:09 
AnswerRe: Speech recogination of specific language Pin
Duncan Edwards Jones26-Aug-14 5:51
professionalDuncan Edwards Jones26-Aug-14 5:51 
GeneralRe: Speech recogination of specific language Pin
Pete O'Hanlon26-Aug-14 6:57
mvaPete O'Hanlon26-Aug-14 6:57 
GeneralRe: Speech recogination of specific language Pin
Duncan Edwards Jones26-Aug-14 7:02
professionalDuncan Edwards Jones26-Aug-14 7:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.