How do I call a public function in another page???
-
Using C# how do I access another page within the project and call a function that is public to it? Do I simply declare a variable as that page name and invoke the function on the variable? Does that work even if the page has already been loaded? I guess I'm wondering if I have to use a FindPage() or something in order to get the instance of the page that has already been displayed... I suppose I could just check in the Page_Load for a QueryString and if it's there have the page call the function on it's own but that seems to be harder than it should be...
-
Using C# how do I access another page within the project and call a function that is public to it? Do I simply declare a variable as that page name and invoke the function on the variable? Does that work even if the page has already been loaded? I guess I'm wondering if I have to use a FindPage() or something in order to get the instance of the page that has already been displayed... I suppose I could just check in the Page_Load for a QueryString and if it's there have the page call the function on it's own but that seems to be harder than it should be...
it is simple class call. Forget that it is a page and access the function as in a seperate class. Page 1 namespace TEST { public class PAGE1 : System.Web.UI.Page { -------------------- private void Page_Load(object sender, System.EventArgs e) { PAGE2 obj = new PAGE2(); Response.Write(obj.test()); -------------------------- ------------------- ----------------- Page 2 namespace TEST { public class PAGE2 : System.Web.UI.Page { ------------------------ --------------------------- public string test () { return "SREE"; } ------------------------ --------------------- Sreekumar PP
-
it is simple class call. Forget that it is a page and access the function as in a seperate class. Page 1 namespace TEST { public class PAGE1 : System.Web.UI.Page { -------------------- private void Page_Load(object sender, System.EventArgs e) { PAGE2 obj = new PAGE2(); Response.Write(obj.test()); -------------------------- ------------------- ----------------- Page 2 namespace TEST { public class PAGE2 : System.Web.UI.Page { ------------------------ --------------------------- public string test () { return "SREE"; } ------------------------ --------------------- Sreekumar PP
Well that would work fine but the Page name also happens to be a namespace name (not my code, cannot change it) how do I indicate I want an instance of the page not the namespace? Right now the compiler is erroring because it's treating it as the name space.
-
Using C# how do I access another page within the project and call a function that is public to it? Do I simply declare a variable as that page name and invoke the function on the variable? Does that work even if the page has already been loaded? I guess I'm wondering if I have to use a FindPage() or something in order to get the instance of the page that has already been displayed... I suppose I could just check in the Page_Load for a QueryString and if it's there have the page call the function on it's own but that seems to be harder than it should be...