Search code examples
c#object-reference

Object Instance in C#


Why do I get "Object Reference Not Set to Instance of an Object"

protected void GetData()
{
    ...

    id = this.GetTabControl().ID; //<---------here
}

...

protected ASPxPageControl GetTabControl()
{
    return (ASPxPageControl)this.FindControl("DetailTab");
}

---------I assume the FindControl is not working.


Solution

  • Presumably because GetTabControl() is returning null. We can't tell why without more code though.