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 } } } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- [WCF 4.0新特性] 标准终结点与无(.SVC)文件服务激活
- asp.net-mvc-3 – MVC3 Ajax.ActionLink
- asp.net-mvc – 为什么visual studio 2012会在mvc项目中自动
- 难道.NET Core到R2连中文编码都不支持吗?
- asp.net – 如何为客户端和服务器缓存设置不同的缓存到期时
- asp.net-mvc-4 – 如何将用户没有正确的角色重定向到Not Pe
- asp.net – 从静态类访问Page的当前实例
- asp.net – 在telerik网格的列中使用控件
- ASP.net会话cookie丢失或删除
- ASP.NET – 在屏幕底部显示应用程序生成日期/信息
- asp.net – ASMX Web服务对传入请求使用错误编码
- asp.net-mvc-3 – 我可以在ASp.Net MVC中使用Sys
- 为什么使用ASP.NET OutputCache继续返回200 OK,而
- asp.net-web-api2 – Swagger中的数据注释
- ASP.Net控件如何从其数据源读取?
- 在ASP.Net中使用参数
- asp.net-mvc-3 – 将ASP.NET MVC 3 Web角色添加到
- asp.net-mvc – DropDownList设置在asp.net MVC中
- asp-classic – 检查VBScript中是否存在Object
- asp.net-mvc – 单元测试中的ViewResult.ViewNam