当前位置: 动力学知识库 > 问答 > 编程问答 >

asp.net mvc - Implementing UpdatePanel functionality with PartialViews - need help getting started

问题描述:

I'm fairly new to MVC, and need help understanding partial updates implementation similar to UpdatePanel functionality.

I have certain filters on the LHS of the page and a table(DataTable) on the RHS. When the user selects a filter, I want the table data to change according to the filter. I'm trying to load only the PartialView containing the table instead of loading the whole page. However, I am running into difficulties at the beginning itself.

Questions -

Can something like this be achieved using Html.BeginForm? Like shown here.

I can't really find detailed documentation on Html.BeginForm, the MSDN site explains the technicalities, but I'm really not sure whether it is necessary to always use it, and where it is absolutely required.

What I've tried -

I've tried using jQuery.load() shown here. However, when I try to load my partial view like this, i run into a 400 Bad Request error.

All I'm doing here is -

In the View -

I've tried this -

$('#contentDiv').load('<%= @Url.Action("Index", "Grid") %>');

and this -

$.post('<%= @Url.Action("Index", "Grid")%>', function (data) {

$('#contentDiv').html(data); }

I've also tried using #get and that doesnt work either.

In the controller -

 public ActionResult Index()

{

List<Models.GridData> tableData= new List<GridData>();

try

{

tableData= hvUtil.FillGrid();

return PartialView(notes);

}

Can anyone suggest how to get things working?

网友答案:

It looks like you're using an odd combination of Razor and ASCX syntax. Have you looked at the javascript that gets generated?

This will probably get you closer to what you want:

$('#contentDiv').load('@Url.Action("Index", "Grid")');  
分享给朋友:
您可能感兴趣的文章:
随机阅读: