【问题标题】:Controller doesn't receive all parameters within the form控制器没有收到表单中的所有参数
【发布时间】:2011-07-29 00:08:45
【问题描述】:

在我的 MVC Web 应用程序中,我正在运行具有以下签名的 ActionResult:

 Public Function Create(ByVal article As Article_Ad) As ActionResult

在我的 ASPX 页面中,我声明了以下表单,哪些字段对应于模型,它是强类型的:

<%  Using Html.BeginForm(ViewData("action").toString, "Article", FormMethod.Post, New With { .class = "basic"}) %>
<div class="inner-form">
    <%= Html.MyValidationSummary("Por favor corrija os erros e tente novamente.")%> 
    <dl>
        <dt><label for="name">Descri&ccedil;&atilde;o:</label></dt>
        <dd><%= Html.TextBox("description", Model.description, New With {.class = "txt"})%></dd>
        <dt><label for="type">Tipo:</label></dt>
        <dd><%= Html.DropDownList("type", New SelectList(ViewData("typeList"), "value", "text", Model.type), New With {.class = ""})%></dd>
        <dt id="image_dt"></dt>
        <dd id="image_dd">
        <fieldset id="img_fieldset">
        <legend style="font-weight: bold;">Imagem</legend>
        <label for="portrait_image_url">Url da Imagem:</label>
        <%= Html.TextBox("image_url", Model.image_url, New With {.class = "txt"})%>
        <label for="portrait_bigimage_url">Url da Imagem Portrait:</label>
        <%= Html.TextBox("portrait_bigimage_url", Model.portrait_bigimage_url, New With {.class = "txt"})%>
        <label for="landscape_bigimage_url">Url da Imagem Landscape:</label>
        <%= Html.TextBox("landscape_bigimage_url", Model.landscape_bigimage_url, New With {.class = "txt"})%>
        </fieldset>
        </dd>
        <dt id="video_dt"></dt>
        <dd id="video_dd">
        <fieldset id="video_fieldset">
        <legend style="font-weight: bold;">Video</legend>
        <label for="video_url">Url do Video:</label>
        <%= Html.TextBox("video_url", Model.video_url, New With {.class = "txt"})%>
        <label for="video_fullscreen">Url do Video Fullscreen:</label>
        <%= Html.TextBox("video_fullscreen", Model.portrait_bigimage_url, New With {.class = "txt"})%>
        </fieldset>
        </dd>
        <dt></dt>
        <dd><input class="button" type="submit" name="submitButton" value="Gravar" /> <input class="button" type="submit" name="submitButton" value="Cancelar" /></dd>
    </dl>
</div>
<% End Using%>

现在发生的情况是,当我提交此表单时,只有 description 属性分配给我的对象。 我想知道为什么其他属性没有在我的班级中填写(我检查了提琴手,一切都被正确发送)。

【问题讨论】:

    标签: vb.net asp.net-mvc-2


    【解决方案1】:

    确保您的属性在您的Model 中。

    您还可以确保 View 继承您的 Model 以获得智能感知。

    Inherits="System.Web.Mvc.ViewPage(Of Your Model)" %&gt;

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-04
      • 2019-06-11
      • 1970-01-01
      • 2023-03-13
      • 2017-04-16
      相关资源
      最近更新 更多