A code behind is in fact a class and can be called
Ensure the method you are calling is public.
Ensure the method you are calling does not rely on elements on its page like
textboxes etc.
Hope this can help, haven't the time to test it, but should work
Here goes:
First page:
namespace MyNamespace
{
public class FirstPage : System.Web.UI.Page
{
public void DoSomething() //make sure public
{
//HERE IS STUFF YOU WANT TO DO FROM ANOTHER PAGE
//Like populate a database or return a string - but then would
be public string DoSomething()
}
}
}
Second page:
namespace MyNamespace
{
public class FirstPage : System.Web.UI.Page
{
private void DoSomethingFromFirstPage()
{
MyNamespace.FirstPage.DoSomething(); //don't need MyNamespace if
in same class (like this example)
}
}
}
<ne***********@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Hi, I have my .aspx page and its .cs codebehind page that Visual Studio
created.
What if I want to create a function or class in another .cs page but
want to use it in the codebehind page. How can I reference this new
c-sharp (or vb.net page) in the codebehind page? Thanks.