How do I get a reference to the Page object in an asmx it calls
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 return开发者_Python百科ing 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
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. ;-)
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.
精彩评论