asp.net – 使用ViewComponent的Ajax
发布时间:2020-12-16 09:42:11  所属栏目:asp.Net  来源:网络整理 
            导读:如何在Asp.Net Core中使用 AJAX for ViewComponent?那就是调用@ Component.Invoke方法(“ComponentName”,SomeData); ViewComponent将涉及各种视图,具体取决于SomeData而不重新启动主视图. 更新 我的解决方案是: $(function () { $(Container).load('Contr
                
                
                
            | 
 如何在Asp.Net Core中使用 
 AJAX for ViewComponent?那就是调用@ Component.Invoke方法(“ComponentName”,SomeData); ViewComponent将涉及各种视图,具体取决于SomeData而不重新启动主视图. 
  
  更新 我的解决方案是: $(function () {
      $(Container).load('ControllerName/ControllerAction',{
                ArgumentName: ArgumentValue });
                                                 });控制器: public IActionResult ControllerAction(string value)
        {
           return ViewComponent("ViewComponent",value);
        }有没有办法在以前的版本中直接使用ViewComponent作为AjaxHelpers? 解决方法
 你的解决方案是对的. 
 From the docs: 
  
  
  
 正如您所建议的那样,a lightweight controller可以作为ViewComponent的AJAX代理. public class MyViewComponentController : Controller 
{
    [HttpGet]
    public IActionResult Get(int id) 
    {
        return ViewComponent("MyViewComponent",new { id });
    }
}(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! | 
相关内容
推荐文章
            站长推荐
            
        热点阅读
            