好的,我遇到了同样的问题,这是我的发现:
首先是来源-1.7976931348623157E+308
。它等于在Sys.Application.init 事件处理程序之一中调用的Minimum
属性:AjaxControlToolkit.NumericUpDownBehavior
Sys.Application.add_init(function() {
$create(AjaxControlToolkit.NumericUpDownBehavior, {"Maximum":1.7976931348623157E+308,"Minimum":-1.7976931348623157E+308, /* other non relevant stuff */);
});
所以,这里没有魔法,只是一个最小值Double
。Minimum
是与版本 10618 相比的新属性。
其次,为什么页面一显示就显示呢?发生这种情况是因为在值(等于参数 from )readValue
中定义的内部函数如果为空则分配给输入。来源:AjaxControlToolkit.NumericUpDownBehavior.prototype
this._min
Minimum
$create
readValue
readValue : function() {
/// <summary>
/// Parse value of textbox and this._currentValue to be that value.
/// this._currentValue = this._min if some there is an exception
/// when attempting to parse.
/// Parse int or string element of RefValues
/// </summary>
if (this._elementTextBox) {
var v = this._elementTextBox.value;
// The _currentValue of NumericUpDown is calculated here
// if textbox empty this._currentValue = this._min
if(!this._refValuesValue) {
if(!v) {
this._currentValue = this._min;
} else {
try {
this._currentValue = parseFloat(v);
} catch(ex) {
this._currentValue = this._min;
}
}
if(isNaN(this._currentValue)) {
this._currentValue = this._min;
}
// And assigned here. In case of empty input we will get -1.7976931348623157E+308 if Minimum was not changed
this.setCurrentToTextBox(this._currentValue);
this._valuePrecision = this._computePrecision(this._currentValue);
} else {
if(!v) {
this._currentValue = 0;
} else {
var find = 0;
for (var i = 0; i < this._refValuesValue.length; i++) {
if (v.toLowerCase() == this._refValuesValue[i].toLowerCase()) {
find = i;
}
}
this._currentValue = find;
}
this.setCurrentToTextBox(this._refValuesValue[this._currentValue]);
}
}
}
之前Minimum
,在版本 10618 中,默认值为0
. Minimum
所以我认为可以通过在扩展器声明中明确指定值来解决所描述的问题:
<ajaxToolkit:NumericUpDownExtender ID="NumericExtenderFooNum" runat="server"
Minimum="0"
TargetControlID="txtFooNum"
TargetButtonDownID="FooBack" TargetButtonUpID
我发现的另一件事是change
事件调度在新版本的 IE 中工作错误(为了使其工作,应该启用兼容性视图,但我认为这不是公共网站的选项)。
问题在于setCurrentToTextBox
功能。如果使用document.createEventevent
创建对象,则始终在处理程序(例如验证处理程序)中。要解决此问题,应交换条件,因此 IE 中的所有事件都将使用createEventObject创建。null
// Current implementation of version 20229
setCurrentToTextBox : function(value) {
// full sources are not shown, only if matters here
if (document.createEvent) {
// event is created using createEvent
} else if( document.createEventObject ) {
// event is created using createEventObject
}
}
}
// Updated implementation
setCurrentToTextBox : function(value) {
// full sources are not shown, only if matters here
if (document.createEventObject) {
// event is created using createEventObject
} else if(document.createEvent) {
// event is created using createEvent
}
}
}