问题:尽管代码相同,但部分视图(PV)页面仅显示在单页中,而不显示在四(4)个PV的页面中.是否需要将参数传递给PV? [英] Problem: Partial View (PV) pages display right in single pages, not in page of four(4) PVs despite identical code. Need to pass parameter to PVs?

查看:82
本文介绍了问题:尽管代码相同,但部分视图(PV)页面仅显示在单页中,而不显示在四(4)个PV的页面中.是否需要将参数传递给PV?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是关于此主题的第三个问题.希望我在完成这个项目时遇到了麻烦.首先,让我们看一下带有Alert_Identifiers的下拉列表的页面-该值从项目的mysql数据库中获取数据. AlertPick.cshtml:

This is the third question on this topic. Hopefully I’ve improved the question as I struggle with wrapping up this project. First, let’s look at the page with the Dropdown list of Alert_Identifiers—the key value that gets data from the mysql database for the project. AlertPick.cshtml:

@model IEnumerable<edxl_cap_v1_2.Models.ContentViewModels.Alert>
@using edxl_cap_v1_2.Models.ContentViewModels

@{
    ViewData["Title"] = "PickAlert";
}

<head>
    <meta name="viewport" content="width=device-width" />
    <link rel="stylesheet" href="~/css/capv1_2_refimp.css" />
    <title>@ViewBag.Title</title>
</head>

    <h4>Alert</h4>
    <div>
        @ViewBag.Message
    </div>

<style>
    tr:nth-child(even) {
        background-color: lightBlue;
    }

    tr:nth-child(odd) {
        background-color: white;
    }
</style>

    <table class="smallText">

    @foreach (var item in Model)
    {
        <tr>
            <td>
                &nbsp;&nbsp;
            </td>
            <td>
                <div id="elementInput">

                    <span class="smallText">
                        @Html.DisplayNameFor(model => model.Alert_Identifier) value
                        <input type="text" name="elementValue" value="@Html.DisplayFor(modelItem => item.Alert_Identifier)" size="60" />
                    </span>

                </div>
            </td>
            <td>
                <text>&nbsp;&nbsp;</text>
            </td>
            <td>
                <form asp-area="" asp-controller="alerts" asp-action="_DetailsAlert" method="post" asp-route-id="@item.AlertIndex">
                    <input type="hidden"
                           name="Identifier"
                           value="@Html.DisplayFor(modelItem => item.Alert_Identifier)">
                    <input type="submit"
                           value="Check Alert">
                </form>
            </td>
            <td>
                <text>&nbsp;&nbsp;</text>
            </td>
        </tr>
        <tr>
            <td>
                &nbsp;&nbsp;
            </td>
            <td>
                <div id="elementInput">

                    <span class="smallText">
                        @Html.DisplayNameFor(model => model.Alert_Identifier) value
                        <input type="text" name="elementValue" value="@Html.DisplayFor(modelItem => item.Alert_Identifier)" size="60" />
                    </span>

                </div>
            </td>
            <td>
                <text>&nbsp;&nbsp;</text>
            </td>
            <td>
                <form asp-area="" asp-controller="infos" asp-action="_DetailsInfo" method="post" asp-route-id="@item.AlertIndex">
                    <input type="hidden"
                           name="Identifier"
                           value="@Html.DisplayFor(modelItem => item.Alert_Identifier)">
                    <input type="submit"
                           value="Check Info">
                </form>
            </td>
            <td>
                <text>&nbsp;&nbsp;</text>
            </td>
        </tr>
        <tr>
            <td>
                &nbsp;&nbsp;
            </td>
            <td>
                <div id="elementInput">

                    <span class="smallText">
                        @Html.DisplayNameFor(model => model.Alert_Identifier) value
                        <input type="text" name="elementValue" value="@Html.DisplayFor(modelItem => item.Alert_Identifier)" size="60" />
                    </span>

                </div>
            </td>
            <td>
                <text>&nbsp;&nbsp;</text>
            </td>
            <td>
                <form asp-area="" asp-controller="areas" asp-action="_DetailsArea" method="post" asp-route-id="@item.AlertIndex">
                    <input type="hidden"
                           name="Identifier"
                           value="@Html.DisplayFor(modelItem => item.Alert_Identifier)">
                    <input type="submit"
                           value="Check Area">
                </form>
            </td>
            <td>
                <text>&nbsp;&nbsp;</text>
            </td>
        </tr>
        <tr>
            <td>
                &nbsp;&nbsp;
            </td>
            <td>
                <div id="elementInput">

                    <span class="smallText">
                        @Html.DisplayNameFor(model => model.Alert_Identifier) value
                        <input type="text" name="elementValue" value="@Html.DisplayFor(modelItem => item.Alert_Identifier)" size="60" />
                    </span>

                </div>
            </td>
            <td>
                <text>&nbsp;&nbsp;</text>
            </td>
            <td>
                <form asp-area="" asp-controller="resources" asp-action="_DetailsResource" method="post" asp-route-id="@item.AlertIndex">
                    <input type="hidden"
                           name="Identifier"
                           value="@Html.DisplayFor(modelItem => item.Alert_Identifier)">
                    <input type="submit"
                           value="Check Resource">
                </form>
            </td>
            <td>
                <text>&nbsp;&nbsp;</text>
            </td>
        </tr>
        <tr>
            <td>
                &nbsp;&nbsp;
            </td>
            <td>
                <div id="elementInput">

                    <span class="smallText">
                        @Html.DisplayNameFor(model => model.Alert_Identifier) value
                        <input type="text" name="elementValue" value="@Html.DisplayFor(modelItem => item.Alert_Identifier)" size="60" />
                    </span>

                </div>
            </td>
            <td>
                <text>&nbsp;&nbsp;</text>
            </td>
            <td>
                <form asp-area="" asp-controller="EdxlCapMessageViewModels" asp-action="_Assemble" method="post" asp-route-id="@item.AlertIndex">
                    <input type="hidden"
                           name="Identifier"
                           value="@Html.DisplayFor(modelItem => item.Alert_Identifier)">
                    <input type="submit"
                           value="Add All">
                </form>
            </td>
            <td>
                <text>&nbsp;&nbsp;</text>
            </td>
        </tr>
    }
</table>

一旦选择了对应于数据库中一条记录的Alert_Identifier并单击了提交按钮,浏览器就会打开此

Once the Alert_Identifier that corresponds to one record in the database is selected and the submit button is clicked, the browser opens this page

单击检查XXX"提交按钮后,前四行将正常工作.它们一次显示单个数据类别"_DetailsXXX.cshtml"页面.这是显示 _DetailsAlert.cshtml页面的页面屏幕.

The first four rows work correctly when the "Check XXX" submit button is clicked. They show the individual data category "_DetailsXXX.cshtml" page one at a time. Here is the screen of the page showing the _DetailsAlert.cshtml page.

设置该页面以便可以单独查看这些页面,并且合成页面一旦工作,也将在"Review"页面和"Approve"页面中工作.对于此处的组装"页面,单击全部添加"提交按钮时,四个单独的页面将显示为合成在一起,但是当前这些页面显示为

This is set up so that these pages can be reviewed individually and the composite page, once working, will also work in the "Review" page and the "Approve" page. In the case of the "Assemble" page here, the four individual pages are intended to appear composited together when the "Add All" submit button is clicked, but currently these pages appear without data values for the data items.

我还将探访一些以前帮助过我的经验丰富的人,我还研究了一种完全不同的注入机制,用于将数据注入程序中需要的地方,我会考虑在其中使用后续规范.

I am also going to ping a couple of more experienced people who have helped me previously to take a look at this, I am also studying a wholly different injection mechanism for injecting data into the program where needed which I will consider using in the follow-on specfications.

最后,我是GitHub.com上的 rexbroo ,您可以在该仓库中找到几乎相同的Visual Studio程序:edxl_cap_v1_2-VS4Win(对于Windows)和edxl_cap_v1_2-VS4Mac(对于Mac)和edxl_cap_v1_2,sql-mysql-VisualStudio,其中数据库的最新转储值为20180928.

Lastly, I am rexbroo at GitHub.com where you can find nearly identical Visual Studio programs in the repos: edxl_cap_v1_2-VS4Win (for Windows) and edxl_cap_v1_2-VS4Mac (for Mac) and edxl_cap_v1_2,sql-mysql-VisualStudio where the most current dump of the database is 20180928.

推荐答案

 <input type="text" name="elementValue" value="@Html.DisplayFor(modelItem => item.Alert_Identifier)" size="60" />

您无需在此处使用@ Html.DisplayFor助手.只需使用:

You don't need to use the @Html.DisplayFor helper here. Just use:

<input type="text" name="elementValue" value="@item.Alert_Identifier" size="60" />

任何输入值都不应使用Html.DisplayFor.当您真正想要的只是属性的值时,即在该值中插入一个标记.

None of your input values should be using the Html.DisplayFor. That is inserting a tag into the value when all you really want is the value of the property.

我还质疑在页面上使用多种形式的原因.您能使用一个表格并发布到一个动作中吗?您是否需要发布?可以将操作重构为get并让您使用<a>标记代替吗?

Also, I question the reason for using multiple forms on a page. Could you use a single form and post to a single action? Do you need to post at all? Could the action be refactored into a get and let you use a <a> tag instead?

这篇关于问题:尽管代码相同,但部分视图(PV)页面仅显示在单页中,而不显示在四(4)个PV的页面中.是否需要将参数传递给PV?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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