Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

i am new in mvc...now learning but for a long time i am attach with asp.net web form technology. many way we can load user control in webform.

1) suppose when user click any button then a postback occur and a server side method call. from that server side method we can instantiate user control or load user control and add it to page from code behind.

2) another way we can load user control dynamically by jquery. we can call server side function by jquery. and from that function we can load user control and get the user control html and send that html of the usercontrol to jquery function as return result.

so i believe the same thing can be done in mvc too. so discuss all the possible way to load partial view dynamically at client side from action method and also jquery.

how to get the html of partial view here from action method ? please discuss point wise and with sample code.....because i want to learn all good tricks.

share|improve this question

1 Answer 1

Depending on your requirements there are a few scenarios available to you:

1) Utilize a combination of Javascript and jQuery to do an ajax call, get a JSON result, and then reneder the control from a call to a partial method and $("#element").html({jsondata}).

2) Utilize the AJAXForm object to present a form that will be replaced on submission with your desired user control (called from a partial).

3) Pre-render the partial but have it hidden and on successful submission display the hidden control, or update and show depending on your needs.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.