views:

309

answers:

2

i have a process that makes calls to a webservice and handles the responses, some of the responses require some user input so they can be handled. When user input is required i want to trigger an event, in the event handler i want to display a form to the page then wait until the user input is posted back then have the event handler return the user input to the calling method.

I am having difficulty with the making the event handler wait for the post back before returning the input, i don't even know if its possible.

A: 

If I understand correctly, I think the problem here is that you're trying to solve the problem using a very simple event-based system. What you need to be doing is creating your own (very simple) workflow system for such a task and also try to separate out some of the back-end logic from the UI handling (ASP.NET MVC framework would be ideal for this, though I see you are using WebForms, which nonetheless isn't a big problem). Now this "workflow" doesn't necessarily need to be complex. Start off by breaking down the actions performed by your application into some sort of flow diagram. If you can see pretty straightforward dependencies, then it may just be a matter of implementing a basic state machine. As a general pointer to dealing with states in web applications (of all kinds: application, session, view), have a read through some of the links on this page. I'm afraid I can't really provide you with anything more specific from what you've described (perhaps I'm missing something obvious however). If you'd like to clarify the tasks that your website/web app needs to perform, then I might be able to give some code examples, but I suspect that just treating this problem analytically/from a flow perspective should give you a good solution.

Noldorin
A: 

Personally, I prefer Noldorin's suggestion of figuring out a workflow and using that to determine when to ask for input. Keep in mind that server events won't do anything as far as client-side rendering is concerned unless they happen when the user is making their request...in which case you've already got a workflow and have no need for events.

You could work around this by keeping the client machine in communication with the server. For example check for new events in the Tick event of an <asp:Timer> control. This solution is practical if your goal is to, for example, have an update panel or something that says the server is XX% done processing the user's request, and ask for user input once processing is done.

Brian