Prev: modify default xml sitemap provider to allow images
Next: How to modify the HTTP Header for a WebService in .NET 2.0(RFC2617)
From: Peter K on 28 Apr 2010 21:54 Hi, is the following a reasonable way to do things, or what would be better? The set up is as follows: I have an aspx, with many ascx's on it. The ascx's are not aware of each other, but they do depend on data from each other. Eg. (1) "search ascx" which accepts user input, and issues a request to a url and receives the returned xml (a list of shop data). (2) "raw display ascx" which displays the xml as-is. (3) "list display ascx" which processes the xml and displays only the returned "shop names" from the xml. The "search ascx" has a "search event" which the main aspx subscribes to. When the "search ascx" receives the xml, it signals the "search event", and the aspx then receives the xml string in its handler method. The aspx calls "SetResults" methods on the ascx's, which can then perform the handling and display they are required to do. Eg the "raw display ascx" simply formats the xml "beautifully" and displays it, while the "list display ascx" processes the xml to retrieve the shop names. But, the aspx only really knows it has a "search ascx" - there could be many types of "results handler" ascx's. So I make the ascx's implement a "IResultsHandler" interface (which has a "SetResults" method). When the aspx's event handler for results is called, it loops over all its controls, finds those that implement IResultsHandler, and calls the method. Is that reasonable? Thanks, Peter |