Solved

Call aspx.cs from AppCode

Posted on 2008-06-11
4
599 Views
Last Modified: 2013-12-17
Is it possible to call a method in aspx.cs from Class in AppCode?
0
Comment
Question by:johnkainn
  • 2
  • 2
4 Comments
 
LVL 21

Expert Comment

by:silemone
ID: 21759027
read over this link:

http://www.velocityreviews.com/forums/t104413-20-appcode-folder-support-for-codebehind.html

if this is what yolu're talking about, the answer is yes.
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 21759150
Hello johnkainn,

I don't think that link applies to you (and it is not best practice either as discussed in the thread).

The simple answer is unfortunately no. Partly because of the reasons indicated in the thread mentioned above. You cannot instantiate the partial class (aspx.cs) without loading the whole page. If you have a function that needs to be used both from a page and from another class then it is better for you to move that function out of the page and into a common class where it can be called from wherever is appropriate.

Regards,

TimCottee
0
 
LVL 21

Assisted Solution

by:silemone
silemone earned 100 total points
ID: 21760573
TimCottee's way would also work and i would use this method also.  you can sort of build your own library's by having your own classes.  

However, your question could it be done?  A resounding yes as shown by the link.  Should it be done?  Nothing wrong with it...just better to place methods in a class if you're going to use them constantly.  One of the major pluses of OOP is reusability.
0
 
LVL 43

Accepted Solution

by:
TimCottee earned 150 total points
ID: 21760760
silemone,

The link you gave doesn't actually imply anything of the sort, all this talks about is whether it is possible to place code-behind files in the app_code folder (which it demonstrates is possible though not recommended). It doesn't in any way refer to any method for calling a function coded within that code-behind file from a class that is not part of the page that loads it.

TimCottee
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now