Friday, April 8, 2011

injection user control depending on radio button choice (ASP.NET MVC)

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?

From stackoverflow
  • 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.

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

0 comments:

Post a Comment