An Object reference is required for the non-static field
- by Muhammad Akhtar
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