1

I would like to know if it is possible to update a section of the view asynchronously without moving that section into a partial view, in ASP.NET MVC 3.0. In webforms model, I can have all the mark-up in just one page, but I can still update a section of the page by specifying the target div on the update panel without moving that section into separate user control. partial view is only useful if that HTML fragment is used in multiple views. creating a partial view just for the purpose of asynchronous update will result in HTML for the page scattered in multiple files. I am using Ajax.BeginForm() to make an ajax call to the server. related article for this http://blogs.msdn.com/b/stuartleeks/archive/2011/04/13/asp-net-mvc-partial-rendering-and-ajaxattribute.aspx

4
  • what are you wanting to update the section with? using jquery, you can change the value of anything on the page. Commented Feb 1, 2012 at 17:23
  • I have a grid populated with some data and I need to filter it using the value provided by the user. problem with jQuery is, I need to get the data in Json format and build the html manually in code (unless there is any better way). I like the simple MS Ajax helper, does the same with lot less code and elegant. Commented Feb 1, 2012 at 17:50
  • jquery has lots of grid plugins (maybe too many). Commented Feb 1, 2012 at 17:54
  • 1
    In webforms, when you update just one part of the page, you are actually still rendering all of it. In MVC, you are encouraged to just render the part that is updated (using partial views). If you don't want to use partial views, you can still do it the old way.. just use jQuery to $('#partToUpdate').load('http://www.mysite.com/page #partToUpdate') Note: you will need to use $.ajax() or $.post() with a callback function if it is posted data that you want. Commented Feb 2, 2012 at 8:42

1 Answer 1

1

If you have partial views with passion - you can return JsonResult to your ajax request and build html using javascript (jquery). But there are no analogs to web forms UpdatePanel control that allows to not separate partial view, because each request is action, and action should return view/partial view to generate html. I think that your problem is artificial.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.