我有多个文本框在IE 7和IE 8中显示出奇怪的行为(但不是IE 9 / Chrome):
以下是控件的代码:
<div class="smpoe-field-container smpoe-div-column-four">
<%=Html.EditorFor(m => m.SegmentNumber, new {model = Model})%>
</div>
<div class="smpoe-field-container smpoe-div-column-four">
<%=Html.EditorFor(m => m.AmountOrPercent, new {model = Model})%>
</div>
<div class="smpoe-field-container smpoe-div-column-four">
<%=Html.EditorFor(m => m.RandomLowNumber, new {model = Model})%>
</div>
它们在我的ViewModel中定义如下:
[UIHint("InputTextField")]
[DisplayName("Segment Number")]
[DomainModelProperty(Key = "PCS.SegmentNumber")]
public int SegmentNumber { get; set; }
[UIHint("InputTextField")]
[DisplayName("Amount/Percent")]
[DomainModelProperty(Key = "PCPP.AmountOrPercentValue")]
public decimal AmountOrPercent { get; set; }
[UIHint("InputTextField")]
[DisplayName("High Random Number")]
[DomainModelProperty(Key = "PSD.HighRandomNumber")]
public int RandomHighNumber { get; set; }
增加: 我已经确认我可以通过删除指向我的模板的UIHint来解决此问题。为了弄清楚发生了什么,我目前已将InputTextField删除到以下代码,问题仍然存在:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<div class="smpoe-field-value">
<%=Html.TextBox("", string.Empty)%>
</div>
有没有人有任何线索? 非常感谢您提供的任何帮助。
答案 0 :(得分:0)
通过消除过程我发现了这个:
$('.smpoe-field-value input,.smpoe-field-value textarea,.smpoe-field-value select').live('change', function() {
var parentForm = $(this).parents("form:first")[0];
if(parentForm == undefined)
parentForm = $(this).parents('.smpoe-entity-identifier')[0];
if(parentForm == undefined)
return false;
jQuery.data(parentForm,"FormUpdated",true);
});
返回false导致更改在IE 7/8中被取消,但在IE 9或Chrome中未被取消。
显然,该例程最初是在IE 7/8以外的浏览器上编写/测试的,即使返回false也会出现预期的行为。