我正在开发ASP.Net MVC应用程序,并使用数据注释控制元素属性的表示。直接来自Visual Studio的IIS Express上的结果很好,但是当我部署到UAT服务器时,Annotations失败了。
代码:
Edit.cshtml:
@Html.EditorFor(m => m.GlobalizedElement)
型号:
public class GlobalizedElement
{
[HiddenInput(DisplayValue = false)]
public int Id { get; set; }
[HiddenInput(DisplayValue = false)]
public int ElementId { get; set; }
[HiddenInput(DisplayValue = false)]
public string CultureCode { get; set; }
[DataType(DataType.MultilineText)]
[AllowHtml]
[Display(Name = "InternalDescription", ResourceType = typeof(EntityDataAnnotations))]
[Required(ErrorMessageResourceType = typeof(EntityValidation), ErrorMessageResourceName = "RequiredInternalDescription")]
public string InternalDescription { get; set; }
[DataType(DataType.MultilineText)]
[AllowHtml]
[Display(Name = "InterviewDescription", ResourceType = typeof(EntityDataAnnotations))]
public string InterviewDescription { get; set; }
[DataType(DataType.MultilineText)]
[AllowHtml]
[Display(Name = "ExternalDescription", ResourceType = typeof(EntityDataAnnotations))]
public string ExternalDescription { get; set; }
}
IIS Express演示文稿隐藏了隐藏字段,并使用多行文本框。
部署的IIS演示文稿显示所有字段,仅显示单行文本框。
我在Windows 7旗舰版上使用VS2013,并部署到Windows Server 2008 R2服务器。
提前感谢您的任何帮助。
里卡多 - 表单上没有脚本元素。问题似乎出现在渲染引擎中。 IIS Express服务器的页面源是:
<div class="editor-field">
<textarea class="text-box multi-line" data-val="true" data-val-required="Please enter a internal description" id="GlobalizedElement_InternalDescription" name="GlobalizedElement.InternalDescription">
</textarea> <span class="field-validation-valid" data-valmsg-for="GlobalizedElement.InternalDescription" data-valmsg-replace="true"></span></div>
<div class="editor-label">
<label for="GlobalizedElement_InterviewDescription">Interview description</label>
</div>
<div class="editor-field">
<textarea class="text-box multi-line" id="GlobalizedElement_InterviewDescription" name="GlobalizedElement.InterviewDescription">
</textarea> <span class="field-validation-valid" data-valmsg-for="GlobalizedElement.InterviewDescription" data-valmsg-replace="true"></span></div>
<div class="editor-label">
<label for="GlobalizedElement_ExternalDescription">External description</label>
</div>
For IIS it is:
<div class="editor-label">
<label for="GlobalizedElement_Id">Id</label>
</div>
<div class="editor-field">
<input class="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="GlobalizedElement_Id" name="GlobalizedElement.Id" type="number" value="0" /> <span class="field-validation-valid" data-valmsg-for="GlobalizedElement.Id" data-valmsg-replace="true"></span></div>
<div class="editor-label">
<label for="GlobalizedElement_ElementId">ElementId</label>
</div>
<div class="editor-field">
<input class="text-box single-line" data-val="true" data-val-number="The field ElementId must be a number." data-val-required="The ElementId field is required." id="GlobalizedElement_ElementId" name="GlobalizedElement.ElementId" type="number" value="0" /> <span class="field-validation-valid" data-valmsg-for="GlobalizedElement.ElementId" data-valmsg-replace="true"></span></div>
<div class="editor-label">
<label for="GlobalizedElement_CultureCode">CultureCode</label>
</div>
<div class="editor-field">
<input class="text-box single-line" id="GlobalizedElement_CultureCode" name="GlobalizedElement.CultureCode" type="text" value="" /> <span class="field-validation-valid" data-valmsg-for="GlobalizedElement.CultureCode" data-valmsg-replace="true"></span></div>
<div class="editor-label">
<label for="GlobalizedElement_InternalDescription">InternalDescription</label>
</div>
<div class="editor-field">
<input class="text-box single-line" id="GlobalizedElement_InternalDescription" name="GlobalizedElement.InternalDescription" type="text" value="" /> <span class="field-validation-valid" data-valmsg-for="GlobalizedElement.InternalDescription" data-valmsg-replace="true"></span></div>
<div class="editor-label">
<label for="GlobalizedElement_InterviewDescription">InterviewDescription</label>
</div>
<div class="editor-field">
<input class="text-box single-line" id="GlobalizedElement_InterviewDescription" name="GlobalizedElement.InterviewDescription" type="text" value="" /> <span class="field-validation-valid" data-valmsg-for="GlobalizedElement.InterviewDescription" data-valmsg-replace="true"></span></div>
<div class="editor-label">
<label for="GlobalizedElement_ExternalDescription">ExternalDescription</label>
</div>
<div class="editor-field">
<input class="text-box single-line" id="GlobalizedElement_ExternalDescription" name="GlobalizedElement.ExternalDescription" type="text" value="" /> <span class="field-validation-valid" data-valmsg-for="GlobalizedElement.ExternalDescription" data-valmsg-replace="true"></span></div>