views:

406

answers:

2

I have this Create Event form (asp.net mvc), and i have to change some parts of the form, depending on user's choice. When the user clicks radio buttons, different user controls (ascx files) should be injected inside the form hopefully using Ajax. Any suggestions to do this?

A: 

Wrap your buttons inside forms that are submitted via AJAX (Ajax.BeginForm...). Have the click event submit the form. Using Ajax.BeginForm you can specify the container to be updated with content (UpdateTargetId in the AjaxOptions). Have the form submit to a controller than returns a PartialViewResult based on the form parameters submitted (button values).

If you could have the functionality triggered by links, this is even easier. Just use Ajax.ActionLink and specify the route values necessary to get the proper content. You could, of course, style the links to look like buttons, even radio buttons though that would require some graphics, probably.

tvanfosson
+2  A: 

If you use jQuery you can easily update your form with an ascx or partial html. The following link could help you further

JSC