Solved

Call aspx.cs from AppCode

Posted on 2008-06-11
4
601 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

911 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

23 Experts available now in Live!

Get 1:1 Help Now