控制器不接收表单中的所有参数

时间:2011-07-28 15:33:26

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

在我的MVC Web App中,我运行的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属性被分配给我的对象。 我想知道为什么我的班级没有填写其他属性(我用fiddler检查,一切都正确发送)。

1 个答案:

答案 0 :(得分:1)

确保您的媒体资源位于Model

另外,您可以确保View继承Model以获取智能感知。

Inherits="System.Web.Mvc.ViewPage(Of Your Model)" %>