English 中文(简体)
根据测验点对部分数据进行过滤
原标题:filtering data in partial view based on datepicker on view

我在我的MVC观点上添加了一张破碎的日期。 这一观点具有部分观点。 我需要根据日期绕过者选定日期对我的部分看法进行过滤。 我需要根据日期以部分观点来表示。

I have added partial view like this:

<div id="dvGames" class="cornerdate1"> 
    <% Html.RenderPartial("Partial3"); %>                          
</div>
最佳回答

You have several problems you need to address here:

  1. You need to have a strongly-typed partial view so you can pass in the right data. Right now you aren t passing in a model to your partial view so I assume it isn t strongly typed.
  2. You need to have a controller action to populate your model for the selected date and pass it to your partial view.
  3. You need some javascript (i.e. jquery) to request an update to your partial view div when the date is selected.

Your jquery would look something like this:

$("#myDatePicker").datepicker({
  onSelect: function(dateText, inst) {
    $("#dvGames").load( /Home/Partial3/  + dateText );
  }
});

你们的控制者的行动也希望:

public ActionResult Partial3(DateTime? id)
{
    MyModel model = new MyModel();
    // Populate model
    return PartialView(model);
}

牢记“Home/Partial3/”只有在你所在的地点扎根的情况下才能成为一条道路。 你们应当利用Url.Action来确定实际道路。 通常我使用Ajax。 BeginForm(你可以找到大量的例子)而不是 j。 装货后使用舱,要求提交表格。 这样,我的个人简历就界定了在Ajax参数中部分考虑的URL。 接着,我的《支离破碎法》是完全可行的,因为它只是提出一种具体的形式,而且没有必须知道任何一条路。 你的投入信标,你正在转换成一个日期,是Ajax确定的形式。 最终将提交这一行动。 你的部分观点确实是,NOT必须在形式内。 仅具体说明“dvGames”为“更新指标” 页: 1

::

$("#myDatePicker").datepicker({
  onSelect: function(dateText, inst) {
    $(this).closest( form ).trigger( onsubmit );
  }
});

希望会有所帮助。

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签