Solved

Call aspx.cs from AppCode

Posted on 2008-06-11
4
612 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

749 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