An Object reference is required for the non-static field
Posted
by Muhammad Akhtar
on Stack Overflow
See other posts from Stack Overflow
or by Muhammad Akhtar
Published on 2010-04-28T06:19:15Z
Indexed on
2010/04/28
6:23 UTC
Read the original article
Hit count: 620
I have make my existing method to static method to get access in javascript, like..
[WebMethod(EnableSession = true), ScriptMethod()]
public static void Build(String ID)
{
Control releaseControl = LoadControl("~/Controls/MyControl.ascx");
//An Object reference is required for the non-static field, mthod or property
// 'System.Web.UI.TemplateControl.LoadControl(string)'
plc.Controls.Add(releaseControl); // where plc is place holder control
//object reference is required for the nonstatic field, method, or property '_Default.pl'
}
When I build I am getting error and I have posted these in comments below each line
before converted it to static method, it working perfectly.
Please suggest me the solution of my issue.
Thanks
© Stack Overflow or respective owner