わかりました、私は同じ問題を抱えています。ここに私の発見があります:
まずはソースです-1.7976931348623157E+308
。これは、 Sys.Application.init イベントハンドラーの 1 つで呼び出される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 と比較して新しいプロパティです。
次に、ページが表示されるとすぐに表示されるのはなぜですか? これは、値( のパラメーターと等しい) で定義されている内部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
私が発見したもう 1 つのことはchange
、新しいバージョンの IE ではイベント ディスパッチが正しく動作しないことです (動作させるには、互換表示を有効にする必要がありますが、これは公開 Web サイトのオプションではないと思います)。
問題はsetCurrentToTextBox
機能にあります。event
object は、 document.createEventnull
を使用して作成された場合、常にハンドラー (検証ハンドラーなど) にあります。この問題を解決するには、条件を交換して、IE のすべてのイベントがcreateEventObjectを使用して作成されるようにする必要があります。
// 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
}
}
}