我怎样才能刷新一个ASP.NET MVC用户控件与jQuery? [英] How can I refresh a ASP.NET MVC UserControl with jQuery?

查看:98
本文介绍了我怎样才能刷新一个ASP.NET MVC用户控件与jQuery?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个直接与数据库中的用户控件,也就是说,它不是由任何行动渲染。它的工作原理independly。

I have a UserControl that binds directly to database, that is, it's not rendered by any Action. It works independly.

不过,从时间到的时候,我必须刷新它从数据库中获得的新信息。
我已经通过Ajax的jQuery的用户控件清爽的工作,但在所有这些情况下,我做了一个动作,使服务。

But, from times to times I have to refresh it to get new information from database. I've already worked with refreshing UserControls in jQuery via Ajax, but in all of these cases, I had a Action to make the service.

但是,这一次我没有行动,因为这直接UC获取信息。

But, this time I don't have a Action since this UC gets its information directly.

有谁知道如何做到这一点?

Does anyone know how to do this?

非常感谢!

推荐答案

更新:

您需要调用的返回控制视图的操作。例如:

You need to call an action that returns the controls view. Example:

public ActionResult GetFooControl()
{
   return View("~/Views/Shared/Foo.ascx");
}

然后使用jQuery的负载功能,以刷新控件容器内的HTML。

Then use the jQuery's load function to refresh the inner HTML for the control's container.

$('#mycontrolContainer').load('../MyController/GetFooControl');

这篇关于我怎样才能刷新一个ASP.NET MVC用户控件与jQuery?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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