- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
下面是我的代码的简短版本,非常基础。在我的页面模型中,我有一个要传递给 Action() 方法的可枚举字段。问题是,就在 View 中调用 Html.Action() 之前,它不是空的。但是,一旦它进入子操作,它就会突然变为 null - 就好像它没有被传入一样。
在类似的尝试中,我尝试执行 Html.Partial("OverlayAlerts", Model.Alerts) 并且它仍然将数据作为 null 传递。我不确定这是为什么。调试时,在调用 Action()(或 Partial())方法之前填充 Alerts 属性。有任何想法吗?谢谢。
页面 Controller 操作
public ActionResult Index()
{
var model = new DashboardModel()
{
...
Alerts = GadgetService.GetAlerts()
...
};
return View(model);
}
型号:
public class DashboardModel
{
...
public IEnumerable<AlertMessage> Alerts { get; set; }
...
}
查看
<%: Html.Action("GetOverlayAlerts", Model.Alerts)%>
CHILD ACTION(同一 Controller )
[ChildActionOnly]
public ActionResult GetOverlayAlerts(IEnumerable<AlertMessage> alerts)
{
alerts.Any(); // <--- FAILS: alerts is passed through as null?
}
最佳答案
试试这个:
<%: Html.Action("GetOverlayAlerts", new {alerts = Model.Alerts})%>
关于c# - Html.Action ("MyView", Model.SomeData) 作为 null 传入?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3773006/
这个问题已经有答案了: Difference Between Firestore Set with {merge: true} and Update (5 个回答) 已关闭 4 年前。 假设我的 Fi
我正在使用 asp.net mvc - ajax 和 jQuery...我有一个名为“Books”的模型类型,其中包含属性“TableOfContents”该属性包含以下格式的数据: TableOfC
遇到这个片段 var someDataJSON = jQuery.parseJSON(JSON.stringify(someData)); 根据 MDN内部“方法将 JavaScript 值转换为 J
这个问题在这里已经有了答案: When to use an elaborated type specifier (5 个回答) 1年前关闭。 我试图用 C++ 制作一棵树,但遇到了这段代码,这让我很困
下面是我的代码的简短版本,非常基础。在我的页面模型中,我有一个要传递给 Action() 方法的可枚举字段。问题是,就在 View 中调用 Html.Action() 之前,它不是空的。但是,一旦它进
我是一名优秀的程序员,十分优秀!