C# Html.ValidationmMessage在WCF服务的客户端上不显示消息错误

C# Html.ValidationmMessage在WCF服务的客户端上不显示消息错误,c#,wcf,validation,C#,Wcf,Validation,创建Asp.net Web客户端以测试WCF服务时,WCF服务上的模型类: public partial class Product { [DatabaseGenerated(DatabaseGeneratedOption.None)] public int Id { get; set; } [Required] [StringLength(30)] public string ProductName { get; set; } [Column

创建Asp.net Web客户端以测试WCF服务时,WCF服务上的模型类:

public partial class Product
{
    [DatabaseGenerated(DatabaseGeneratedOption.None)]
    public int Id { get; set; }

    [Required]
    [StringLength(30)]
    public string ProductName { get; set; }

    [Column(TypeName = "money")]
    public decimal Price { get; set; }

    public int Quantity { get; set; }
}
客户端Scaffold生成的Create视图为:

@using (Html.BeginForm()) 
{
@Html.AntiForgeryToken()

<div class="form-horizontal">
    <h4>Product</h4>
    <hr />
    @Html.ValidationSummary(true, "", new { @class = "text-danger" })
    <div class="form-group">
        @Html.LabelFor(model => model.Id, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.Id, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.Id, "", new { @class = "text-danger" })
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.ProductName, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.ProductName, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.ProductName, "", new { @class = "text-danger" })
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.Price, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.Price, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.Price, "", new { @class = "text-danger" })
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.Quantity, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.Quantity, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.Quantity, "", new { @class = "text-danger" })
        </div>
    </div>

    <div class="form-group">
        <div class="col-md-offset-2 col-md-10">
            <input type="submit" value="Create" class="btn btn-default" />
        </div>
    </div>
</div>
问题是@html.ValidationMessageFor只显示Id、价格和数量的消息。它不适用于ProductName字段。呈现代码html为:

      <input class="form-control text-box single-line" data-val="true" data-val-number="The field Id must be a number." 
          data-val-required="The Id field is required." id="Id" name="Id" type="number" value="" />
      <span class="field-validation-valid text-danger" data-valmsg-for="Id" data-valmsg-replace="true"></span>

      <input class="form-control text-box single-line" id="ProductName" name="ProductName" type="text" value="" />
      <span class="field-validation-valid text-danger" data-valmsg-for="ProductName" data-valmsg-replace="true"></span>

ProductName字段的输入标记不包括数据值,需要数据值,如id、价格和数量。我如何解决这个问题

那么这个模型来自wcf服务?据我所知,属性没有序列化。您看到整数消息的原因是,它们是由帮助程序自动实现的,因为不可为空。谢谢!您知道在客户机上维护验证的任何解决方案吗?您是否找到过此问题的解决方案?我在验证方面也有同样的问题。