Communication Between asp.net files
-
I have 2 asp.net files: default.aspx.cs and test.aspx.cs How can I call methods from test.aspx.cs from default.aspx.cs? I can't seem to call methods from a different file unless it's in my appcode folder.
/\ |_ E X E GG
i think function calling is posible if class is placed in appcode folder.
Sonia Gupta Soniagupta1@yahoo.co.in Yahoo messengerId-soniagupta1 Love is Friendship and Friendship is Love....
-
i think function calling is posible if class is placed in appcode folder.
Sonia Gupta Soniagupta1@yahoo.co.in Yahoo messengerId-soniagupta1 Love is Friendship and Friendship is Love....
Try this code Use this line where u want to call Function In .aspx page <%@ PreviousPageType VirtualPath="~/index.aspx" %> in .aspx.cs this.PreviousPage.Login(); //Make sure your method is public Best Regard Pathan -- modified at 0:54 Wednesday 1st August, 2007
---------------------------------------------------
-
i think function calling is posible if class is placed in appcode folder.
Sonia Gupta Soniagupta1@yahoo.co.in Yahoo messengerId-soniagupta1 Love is Friendship and Friendship is Love....
-
I have 2 asp.net files: default.aspx.cs and test.aspx.cs How can I call methods from test.aspx.cs from default.aspx.cs? I can't seem to call methods from a different file unless it's in my appcode folder.
/\ |_ E X E GG
Someone else was asking this the other day. You can't. You just can't. test.aspx.cs does NOT exist when default.aspx.cs is running. The class instances are created as the pages are served. If you have stuff you want to be able to call from many pages, give them a common base class.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
Someone else was asking this the other day. You can't. You just can't. test.aspx.cs does NOT exist when default.aspx.cs is running. The class instances are created as the pages are served. If you have stuff you want to be able to call from many pages, give them a common base class.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
Try this code Use this line where u want to call Function In .aspx page <%@ PreviousPageType VirtualPath="~/index.aspx" %> in .aspx.cs this.PreviousPage.Login(); //Make sure your method is public Best Regard Pathan -- modified at 0:54 Wednesday 1st August, 2007
---------------------------------------------------
imran i tried ur code i got the following exceptions Object reference not set to an instance of an object. at the following line this.PreviousPage.Login();
Sonia Gupta Soniagupta1@yahoo.co.in Yahoo messengerId-soniagupta1 Love is Friendship and Friendship is Love....
-
imran i tried ur code i got the following exceptions Object reference not set to an instance of an object. at the following line this.PreviousPage.Login();
Sonia Gupta Soniagupta1@yahoo.co.in Yahoo messengerId-soniagupta1 Love is Friendship and Friendship is Love....
Now try this take two page test1.aspx and test2.aspx Take LinkButton in test1.aspx LinkButton and write public method i.e public string Login() { return "Welcome"; } Now In test2.aspx <%@ PreviousPageType VirtualPath="~/test1.aspx" %> Call Method in page load event Response.Write(this.PreviousPage.Login()); Run test1.aspx and click on LinkButton Best Regard Pathan ---------------------------------------------------
-
Now try this take two page test1.aspx and test2.aspx Take LinkButton in test1.aspx LinkButton and write public method i.e public string Login() { return "Welcome"; } Now In test2.aspx <%@ PreviousPageType VirtualPath="~/test1.aspx" %> Call Method in page load event Response.Write(this.PreviousPage.Login()); Run test1.aspx and click on LinkButton Best Regard Pathan ---------------------------------------------------
imran, have u tested the code u r providing.
Sonia Gupta Soniagupta1@yahoo.co.in Yahoo messengerId-soniagupta1 Love is Friendship and Friendship is Love....
-
imran, have u tested the code u r providing.
Sonia Gupta Soniagupta1@yahoo.co.in Yahoo messengerId-soniagupta1 Love is Friendship and Friendship is Love....
Yes
---------------------------------------------------
-
Now try this take two page test1.aspx and test2.aspx Take LinkButton in test1.aspx LinkButton and write public method i.e public string Login() { return "Welcome"; } Now In test2.aspx <%@ PreviousPageType VirtualPath="~/test1.aspx" %> Call Method in page load event Response.Write(this.PreviousPage.Login()); Run test1.aspx and click on LinkButton Best Regard Pathan ---------------------------------------------------
well i have tested this code it really works great