How to call aspx method from ascx?

C

Cowboy \(Gregory A. Beamer\)

Why not move the method to a code file that each can call? That is the first
step towards actually making a reusable library. While there are other ways
of handling this, the fact that you are reusing at the lower levels
indicates the functionality is needed elsewhere.

Or, do you not really need to "call" the method, but have it fire during
postback. If so, create event delegates in your ASCX that fire off events
that are handled in the page. This leads to a properly encapsulated user
control.

Perhaps something else?
 
W

Weblancer

Yes mate thats exactly what i gonna do now i mean to write event
delegate. I wonder if it is any possibility to catch server events? i
mean when u press the button in UC some how parent knows that is not
his event and only UC after post_back loads it. So it sends some kind
of an event to the server (UC_Name.EVentName or smth ). So if it would
be possible it would be great :) Because on the middle of the post
back u could check if UC button was clicked do this and that :)
 
I

IfThenElse

If you have a button in a UC then the event handler to that button in the
code behind for that UC is called on post back
what is the issue?
 
C

Cowboy \(Gregory A. Beamer\)

There are two basic patterns I employ.

1. UC triggered event - event delegate wired to the page
2. Page triggered event - Have method on UC to get information back to page

Either works and each is useful in different situations. The idea here is to
treat a UC like any other control and encapsulate the functionality so you
are using methods and events to communicate to other programming bits.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top