装订形式值的复杂类型

编程入门 行业动态 更新时间:2024-10-12 01:26:34
本文介绍了装订形式值的复杂类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我使用MVC模式,而现在,并已获得精细,但是我已经得到了完全卡住了​​。

I've used the MVC pattern for a while now and have been getting on fine, however I've got totally stuck.

我有一个视图,显示复杂对象的集合,有部分观点如下:

I have a view which shows a collection of complex objects, with a partial view as follows:

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ThreeSixtyScheduling.Areas.Products.Models.PartsOnOrderModel+PartOnOrder>" %> <tr> <% using (Html.BeginForm("UpdateStockDueDate", "PartsOnOrder", FormMethod.Post)) { %> <td><input type="hidden" name="CallAppointmentDate" value="<%= Model.CallAppointmentDate %>" /><%= Html.DisplayFor(m => m.CallAppointmentDate)%></td> <td><%= Html.HiddenFor(m => m.OrderNumber)%><%= Html.DisplayFor(m => m.OrderNumber)%></td> <td><%= Html.HiddenFor(m => m.JobNumber)%><%= Html.DisplayFor(m => m.JobNumber)%></td> <td><%= Html.HiddenFor(m => m.Part)%><%= Html.DisplayFor(m => m.Part)%></td> <td><%= Html.HiddenFor(m => m.Quantity)%><%= Html.DisplayFor(m => m.Quantity)%></td> <td><%= Html.EditorFor(m => m.StockDueDate)%></td> <td><button type="submit">Save</button></td> <% } %> </tr>

我有一个控制器动作,是以复杂的对象作为它的参数:

I have a controller action that takes the complex object as its parameter:

public ActionResult UpdateStockDueDate(PartsOnOrderModel.PartOnOrder PartOnOrder)

的表格确有其收藏价值 CallAppointmentDate 所以我的理解是,它应适当填充值

The Form does have the value CallAppointmentDate in its collection so my understanding it that it should populate the value appropriately.

我已经尝试了许多排列组合,包括更改名称 PartOnOrder.CallAppointmentDate ,设定的ID以及名称,添加属性,各个参数并没有什么作品

I've tried MANY permutations, including changing the name to PartOnOrder.CallAppointmentDate, setting the IDs as well as the name, adding the properties as individual parameters and nothing works.

我在做什么错了?

推荐答案

默认模型绑定确实基于服务器的当前文化的结合/验证工作。如果你想要做的日期时间绑定/验证基于不同的文化,你必须写的自定义模型粘合剂。

The Default Model Binder does the binding/validation work based upon the current culture of the server. If you want to do the datetime binding/validation based upon a different culture you have to write a custom model binder.

更多推荐

装订形式值的复杂类型

本文发布于:2023-11-16 15:27:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1605513.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:形式   类型

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!