Quantcast
Channel: AjaxControlToolkit Work Item Rss Feed
Viewing all articles
Browse latest Browse all 4356

Commented Unassigned: MaskedEditExtender's ClearMaskOnLostFocus does not work [27427]

$
0
0
Using as an example of starting the April 30 version 4.1.7.0429 version AjaxControlToolkitSampleSite.zip shifting the focus on the textbox the page is not erased the mask, the result is visible in the attached figure.
Comments: Debugging the source code for version 7.1213, c060bbd38a03bbadf6e509e85a90a3faa4df0227, dated 14 Dec 2013, Ajax Control Toolkit .NET 4.5. File: MaskedEditBehavior.pre.js Line: 475 ``` JS , _onBlur : function(evt) { this._InLostfocus = true; var IsValid = this._PeforformValidLostFocus(true); var wrapper = Sys.Extended.UI.TextBoxWrapper.get_Wrapper(this.get_element()); if (IsValid) { // trigger TextChanged with postback if (!this.get_element().readOnly && (this._initialvalue != wrapper.get_Value()) && evt) { this._fireChanged(); } } if (this._beforeClearMaskText != '') wrapper.set_Value(this._beforeClearMaskText); } ``` The last 2 lines of the onBlur event set the value back to the mask. In my case, _beforeClearMaskText is "\_\_/\_\_/\_\_\_\_" The current wrapper value is "" (empty string). IsValid is true in this method (a blank date is valid for me). This last set_Value effectively replaces the empty string by the mask, making Server validation fail. On the server side... File: MaskedEditValidator.cs Method: EvaluateIsValid() Line: 642 (for a Date Validator) ``` C# if (ok && Target.Text.Length != 0) { // more code here try { DateTime dtval = System.DateTime.Parse(Target.Text, ControlCulture); } catch { ok = false; } ``` Target.Text is "\_\_/\_\_/\_\_\_\_" This Parse code is reached because Target.Text.Length is 10 ("\_\_/\_\_/\_\_\_\_") and of course, this line throws an Exception and ok is set to false. So client side validation succeeds but server side fails because of the client setting back the mask at the last minute after client side validation. I run my own version of the toolkit because of bugs like this one. Just wish I knew what this _beforeClearMaskText is meant to do in javascript, so we can fix it ourselves... A proper fix would be nice.

Viewing all articles
Browse latest Browse all 4356

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>