views:

46

answers:

2

I have a page that calls on an asmx within the project (for some ajax stuff). Within that asmx I'm calculating a value and returning it to be output to the screen.

However I need to do a recalculation that includes summing this value with a few others. The function that performs the calculation is in a UserControl on the page.

How do I get a reference to the page object so I can use FindControl to get an instance of the user control so I can call that calcuation function?

Thanks in advance for your help

A: 

OK, I'm confused.... What is calling the ASMX?

It sounds like it's been called from the page via javascript -- which means the Page object is gone.

An ASPX page is a short program, which lives for a moment, spits out some HTML, and terminates. The HTML goes to a browser, which then talks to the ASMX page. Eventually, you postback and a new Page object is created.

James Curran
What a brain fart I had. Duh @ me.I have rarely worked with the Page once it's loaded. Hence my total lack of thinking to remember the Page lifecycle. Thank you for making me realize I need to step away and go take a nap.
TheGeekYouNeed
+4  A: 

You have a design crisis. I am not even going to mention Rube Goldberg.. oops...

If you have some logic that you need to use in a UserControl and for an async pull you should segregate that logic in it's own class that you call from the user control and the pagemethod that you are using for your Ajax.

I am not even going to entertain a solution to your problem as it is. It would be counterproductive for both of us and I may get an aneurysm thinking about it. ;-)

Sky Sanders
Well, this is me just learning - I've already redesigned where I had the data I needed and have that all working. Now, it's just me seeing if I can get a handle to Page that called the asmx.
TheGeekYouNeed
define 'get a handle'. To answer your question, if you are using a pagemethod as an endpoint for your ajax call, NO. pagemethods are static and your controls are not.
Sky Sanders
and I am not trying to bag on you or discourage you. We all have been there.
Sky Sanders
I know - thanks. It's all good. :) I got it now. :)
TheGeekYouNeed