?
Solved

Call aspx.cs from AppCode

Posted on 2008-06-11
4
Medium Priority
?
614 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 400 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 600 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

770 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