使用复选框oncheck / uncheck在mvc razor 4中过滤 [英] use checkbox oncheck/uncheck to filter in mvc razor 4

查看:160
本文介绍了使用复选框oncheck / uncheck在mvc razor 4中过滤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好b $ b

我在updatepanel中使用了复选框onselectedindexchange事件使用asp.net框架中的listview 3.5



但是现在我正在开发mvc razor 4,



我有listview(在html中使用foreach),并希望使用复选框onclick,过滤listview并显示新结果。显示新的结果,整个页面不应该刷新,只有listview应该刷新......



如果未选中复选框,结果应该再次被过滤没有复选框值并显示..



如何在MVC razor 4中执行此操作asp.net c#

Hi
I have used checkbox onselectedindexchange event in updatepanel using listview in asp.net framework 3.5

But now i m developing in mvc razor 4,

and i have listview (using foreach in html) , and want to use checkbox onclick , filter listview and display new results.also when new results are displayed,the whole page should not be refreshed, only listview should be refreshed......

also if checkbox in unchecked , the result should again be filtered without checkbox value and display..

How to do this in MVC razor 4 asp.net c#

推荐答案

Razor和c#是服务器端。 Ajax是客户端。



我认为来自网络表单的人阻力最小的路径是一组工具,如Telerik [ ^ ]





如果没有,那么你总是可以创建一个使用JsonResult而不是ActionResult的控制器端点。您可以从jquery(或常规javascript)调用它并使用结果更新页面。



Razor and c# are server side. Ajax is client side.

I think the path of least resistance for someone from web forms is a set of tools like Telerik[^]


If not, then you can always make a controller endpoint that uses a JsonResult rather than an ActionResult. You can call it from jquery (or regular javascript) and update the page with the results.

function foo(){


.ajax({
url:' yourendpoint'
data:{arg1:value},
success: function (数据){
// 在此更新您的HTML
}
} );
}
.ajax({ url:'yourendpoint', data:{arg1:value}, success:function(data){ //update your html here } }); }







public JsonResult MyEndpoint(/*args here*/)
{
  //do your programming to get the data
  var myData = /*result of your program query*/
  return Json(myData,JsonBehavior.AllowGet);
}







你可以用ajax表格等来复杂化......但我认为这是解释它的最简单方法。




You can get much more complex with ajax forms, etc... but I think that is the easiest way to explain it.


这篇关于使用复选框oncheck / uncheck在mvc razor 4中过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆