Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Re: Call a function from another page

Reply
Thread Tools

Re: Call a function from another page

 
 
Gregory A. Beamer
Guest
Posts: n/a
 
      09-30-2009
"aspfun via DotNetMonster.com" <u53138@uwe> wrote in
news:9ce55c99c84d4@uwe:

> I have two aspx pages: A.aspx and B.aspx. They are in partial class A
> and B. Under Partial Class A, there is a function called it as
> <Protected Function GetID() as string>.
> How to call this function from B.aspx?
> I knew we can create a class file and copy this function into it and
> call it from this class. I just want learn another way to do it.



Technically, you can use a page class in this manner. You simply need to
have the correct namespace and instantiate the class. The issue is you
end up having to make sure you have neutered any events that might fire.
It will likely be a very time consuming effort and go against the grain.
the result will be you will have learned how to conquer something, but
it is a hill that does not need to be conquered. But if you feel the
need to conquer that hill, that is your business, not mine.

On the other hand, you can refactor the logical bits into a class and
run it from both places. This will take less than 5 minutes to
accomplish. But you will not have climbed THAT hill.

If it were me, I would move the application code into class libraries
and use the ASP.NET app as a UI "skin" rather than have it contain
application code. The learning effort would take about as long as using
a page as a class, but would yield a much better application that is
flexible enough to take on different UI types.

So you choice is either learn how to build tiered applications or how to
climb hills.

Peace and Grace,


--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to call function whose function call with arguments is in astring Options grbgooglefan C Programming 4 01-30-2008 05:12 PM
How to call function whose function call with arguments is in astring grbgooglefan C++ 2 01-30-2008 07:18 AM
How to call function whose function call with arguments is in astring Options grbgooglefan C Programming 0 01-30-2008 04:19 AM
defined? for recursive function call v/s defined? for function call stack Alok Ruby 3 04-13-2006 11:53 AM
write a function such that when ever i call this function in some other function .it should give me tha data type and value of calling function parameter komal C++ 6 01-25-2005 11:13 AM



Advertisments