Hi.
I have many web pages. (WebForm1,WebForm2,...)
Just one of them has a method named MyMethod.
All pages can create a object from Class1.
I want that Class1 check page caller and if it has MyMethod(), then call MyMethod().
I used this line into the Class1 constructor:
public Class1(Page page)
{
foreach (System.Reflection.MethodInfo mi in page.GetType().GetMethods())
{
if (mi.Name == "MyMethod")
{
object[] name = new object[] { "mk" };
page.GetType().InvokeMember("MyMethod", BindingFlags.InvokeMethod, System.Type.DefaultBinder, page, name);
}
}
}Class1 calls MyMethod() correctly, but I can't access to Label1 of WebForm1(page that contain MyMethod()).
And an error occurs: Object reference not set to an inst ...
Go to the complete details ...