asp.net – RegularExpressionValidator VS Ajax 1.0.20229
|
我们有一个使用Ajax版本10618运行.NET Framework 2.0的网站. 但是,就是这个旧版本的dll,所以我们计划将它转换为.NET Framework 2.0(AjaxControlToolkit版本20229)的“最新版本”. 在我们的测试中,我们检测到ASP控件的一个问题RegularExpressionValidator,它用于旧版本的正常工作. 每当目标控件的输入与验证不匹配时,控件显示我的 该表达式没有错,因为正如我所说,它与旧版本的Ajax一起工作,我找不到与RegularExpressionValidators和Ajax版本相关的任何内容. PS:验证器和控件都在UpdatePanel内. PS 2:使用较旧的版本,它会在控件中放置一个0,然后在表达式不匹配时向我显示红色星号. 编辑: 这是控制,完全复制: <asp:RegularExpressionValidator ID="ValidateFooOrder"
runat="server" ControlToValidate="txtFooNum"
Text="*" ErrorMessage="Invalid Foo number"
ValidationExpression="^d{0,4}$" ValidationGroup="GenerateFooFile" />
它还附有一个NumericUpAndDownExtender: <ajaxToolkit:NumericUpDownExtender ID="NumericExtenderFooNum" runat="server" TargetControlID="txtFooNum" TargetButtonDownID="FooBack" TargetButtonUpID="FooForward" /> 解决方法好的,我有同样的问题,这里是我的发现:首先是-1.7976931348623157E 308的来源.它等于AjaxControlToolkit.NumericUpDownBehavior的Minimum属性,它在Sys.Application.init Event处理程序之一中调用: Sys.Application.add_init(function() {
$create(AjaxControlToolkit.NumericUpDownBehavior,{"Maximum":1.7976931348623157E+308,"Minimum":-1.7976931348623157E+308,/* other non relevant stuff */);
});
所以,这里没有魔法,只有Double的最小值.最低是与10618版相比的新财产. 接下来,为什么一旦页面显示就显示?这是因为在AjaxControlToolkit.NumericUpDownBehavior.prototype中定义的readValue函数中的值this._min(等于$create中的Minimum参数)如果为空,则分配给输入. 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]);
}
}
}
在最低版本之前,在版本10618中,默认值为0.所以我认为描述的问题可以通过在扩展器声明中明确指定最小值来解决: <ajaxToolkit:NumericUpDownExtender ID="NumericExtenderFooNum" runat="server"
Minimum="0"
TargetControlID="txtFooNum"
TargetButtonDownID="FooBack" TargetButtonUpID
我发现另一件事是,新版本的IE中的更改事件调度失败(使其工作兼容性视图应该启用,但我认为这不是公共网站的选项). 问题在于setCurrentToTextBox函数.如果使用document.createEvent创建,事件对象在处理函数(例如,验证处理程序)中始终为空.要解决此问题,应将条件交换,因此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
}
}
} (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- asp.net-web-api – 如何为代理控制器设置Web API路由?
- asp.net – 是否可以解密和查看ViewState值?
- asp.net-mvc – 人们如何使用编辑器/显示模板与Html助手?
- asp.net-mvc-4 – 将nopcommerce 2.8升级到3.10
- asp.net – 什么时候以明文形式存储密码是个好主意?
- asp.net-mvc-3 – ASP.Net Mvc 3 Url.Action方法使用先前请
- asp.net-mvc – 使用ASP.NET MVC的基础认证
- asp.net – 如何解决“服务器错误在’/’应用程序”错误?
- asp.net – 在WatiN中如何等到回发完成
- asp.net-mvc-3 – Paypal Sandbox MVC3
- ASP.NET MVC中的角色缓存策略
- asp.net-mvc – 无法使用IIS Express在Windows 1
- asp.net-mvc – 如何显示图像从路径在asp.net mv
- ASP.Net AJAX多页面加载功能可能吗?
- asp.net – coldfusion和.net上的单点登录
- ASP.Net httpruntime executionTimeout不工作(而
- asp.net – 为每个网站/应用程序创建单独的IIS应
- 何时使用ASP.NET MVC与ASP.NET Web窗体?
- asp.net-mvc – ASP.NET MVC查看引擎解析顺序
- asp.net – Excel单元格对齐:例如,数值xlLeft,x
