需要帮助将第3个参数传递给复合页面上的4个局部视图。 有关先前寻求答案的尝试,请参见here for effort with screenshots和here for partial answers I’ve tried to use unsuccessfully)。
我很坚持,但是我仍然停滞不前,寻找正确的方法来将int Id
行中的@Html.Partial("_DetailsXxxx", Model.Xxxx, ?)
类型的值的第三个参数传递给{ {1}}页面如下所示:
_Assemble.cshtml
此参数是@model edxl_cap_v1_2.Models.ContentViewModels.EdxlCapMessageViewModel
@{
Layout = "~/Views/Shared/_EdxlLayout.cshtml";
}
<!DOCTYPE html>
<head>
<meta name="viewport" content="width=device-width" />
<link rel="stylesheet" href="~/css/capv1_2_refimp.css" />
<title>Assemble EDXL-CAP Message</title>
</head>
<h4>Assemble EDXL-CAP Message</h4>
<!-- DetailsAlert -->
<div class="content-wrapper">
@Html.Partial("_DetailsAlert", Model.Alert)
</div>
<!-- End of DetailsAlert -->
<!-- DetailsInfo -->
<div class="content-wrapper">
@Html.Partial("_DetailsInfo", Model.Info)
</div>
<!-- End of DetailsInfo -->
<!-- DetailsArea -->
<div class="content-wrapper">
@Html.Partial("_DetailsArea", Model.Area)
</div>
<!-- End of DetailsArea -->
<!-- DetailsResource -->
<div class="content-wrapper">
@Html.Partial("_DetailsResource", Model.Resource)
</div>
<!-- End of DetailsResource -->
的整数,当从下面显示的前SelectedAlertIndex
页的下拉列表中选择Alert_Identifier
时得出:
@model edxl_cap_v1_2.Models.ContentViewModels.AlertViewModel
AlertPick.cshtml
此页面的@{
ViewData["Title"] = "AlertPick";
}
<head>
<meta name="viewport" content="width=device-width" />
<title>@ViewBag.Title</title>
</head>
@{
<h4>@Model.Alerts.Count Alerts</h4>
<form asp-controller="Alerts" asp-action="PickAlert" method="post">
<select class="cap_select" id="cap_select" style="width:100%;max-width:95%;"
asp-for="SelectedAlertIndex" asp-items="Model.Alert_Identifiers">
<option>Select one</option>
</select>
<br />
<input type="submit" name="PickAlert" value="Pick Alert to Assemble EDXL-Cap Message" />
</form>
}
控制器代码:
PickAlert()
还有一些控制器的PickResource,()PickArea()和PickInfo()具有相似的代码,但是我没有在单独的下拉列表中使用它们,但是我想知道public IActionResult PickAlert(Alert obj, int? SelectedAlertIndex)
{
if (SelectedAlertIndex.HasValue)
{
ViewBag.Message = "Alert loaded successfully";
}
return View(_context.Alert.Where(x => x.AlertIndex == SelectedAlertIndex));
}
子句还是类似的东西第三个参数是否需要此参数,因为它指定了与SelectedAlertIndex相等的各个XxxxIndex?例如,这是PickInfo():
Where