Here is my scenario: I am trying to get a value from frontend using AJAX and then want to use this in a non-static method for some calculations. But I am getting an error:
Object reference not set to an instance of an object
I know how to use non-static method/data members in a static method by creating obrect Reference that I did but still error is same.
Code:
[WebMethod]
[WebScript]
public static string refAssignments(getVal rf)
{
string value = rf.valueFromAJAX;
MyClass obj = new MyClass();
string result = obj.analyse(value);
}
Here Analyse()
is a non-static method all I want is to use this method inside the static method refAssignments
.
I tried earlier questions but wasn't successful! Can someone point where I am doing wrong