ASP.NET MVC – Getting User Input in Your Controller

asp.net-mvc

I wanted to get your opinion on best practices for getting user input while doing something in a controller. I am inside a Action method in my controller and I am processing some data. The data may force me to ask the user for further input, based on that input I will then do something with that data.

What is the best practice to go about this?

1) How do I issue an alert or confirm box to get user input from the Controller? This Action is initiated by an update button on a Telerik MVC grid.

2) How do I persist my data from initially processing it, to asking the user for input, and then continue processing the data? It's a fair amount of data.

If the initial request was started from a ajax call in a javascript function, I think I would know how to do this. I would probably have the Action method pass back a JSON object back to the javascript method that would in turn ask the user and then decide which controller action to call and then pass this json object to it.

Am I on the right track here? If so, my problem would be with the Telerik MVC grid. I would need the update event of my grid to be bound client side.

Any help or thoughts on this is appreciated.

Steve

Best Answer

Why not intercept the OnSave event on the grid, client-side, and do your interaction there before allowing the client/server transaction to go forward? I'm not deeply familiar with the Telerik stuff, but it looks as if you can expand the data model to encompass whatever additional information you might need to send to the back end (beyond what's displayed in the grid), and you can modify this information in the event handler.