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: Hi AmarnathBalan!, this workaround only "remove" the prompt char on lost focus. I think you need to add few lines to remove others mask chars or you can try with metoer's solution. This is my last versión: ``` Public Class ToolkitScriptManagerCustom Inherits ToolkitScriptManager Protected Overrides Sub OnPreRender(ByVal e As System.EventArgs) MyBase.OnPreRender(e) Dim sb As New StringBuilder sb.AppendLine("<script>") sb.AppendLine("//CombineScripts = " & Me.CombineScripts.ToString()) sb.AppendLine("function FixMaskedEditExtender() {") sb.AppendLine("if (!Sys) return;") sb.AppendLine("if (!Sys.Application) return;") sb.AppendLine("var els = Sys.Application.getComponents();") sb.AppendLine("if (!els) return;") sb.AppendLine("var mapeo = {}; ") sb.AppendLine("for (i = 0; i < els.length; i++) {") sb.AppendLine(" if (typeof els[i].get_name !== ""undefined"" && els[i].get_name() == ""MaskedEditBehavior"") {") sb.AppendLine(" var mk = els[i];") sb.AppendLine(" var el = mk._element;") sb.AppendLine(" mapeo[el.id] = mk;") sb.AppendLine(" if (typeof $ != 'undefined') {") sb.AppendLine(" $(el).blur(function(event) { ") sb.AppendLine(" var wrapper = Sys.Extended.UI.TextBoxWrapper.get_Wrapper(this); ") sb.AppendLine(" var ClearText = mapeo[this.id]._getClearMask(wrapper.get_Value()); ") sb.AppendLine(" if (ClearText == '') { ") sb.AppendLine(" $(this).val(''); ") sb.AppendLine(" } else { ") sb.AppendLine(" $(this).val($(this).val().replace(new RegExp(mapeo[this.id]._PromptChar, 'g'), '')); ") sb.AppendLine(" $(this).val($(this).val().replace(new RegExp('\\'+ mapeo[this.id].get_CultureThousandsPlaceholder() +'', 'g'),'')); ") sb.AppendLine(" } ") sb.AppendLine(" });") sb.AppendLine(" } else {") sb.AppendLine(" el.onblur = function() { ") sb.AppendLine(" var wrapper = Sys.Extended.UI.TextBoxWrapper.get_Wrapper(this); ") sb.AppendLine(" var ClearText = mapeo[this.id]._getClearMask(wrapper.get_Value()); ") sb.AppendLine(" if (ClearText == '') { ") sb.AppendLine(" this.value = ''; ") sb.AppendLine(" } else { ") sb.AppendLine(" this.value = this.value.replace(new RegExp(mapeo[el.id]._PromptChar, 'g'),'');") sb.AppendLine(" this.value = this.value.replace(new RegExp('\\'+ mapeo[el.id].get_CultureThousandsPlaceholder() +'', 'g'),'');") sb.AppendLine(" } ") sb.AppendLine(" };") sb.AppendLine(" }") sb.AppendLine(" }") sb.AppendLine("}") sb.AppendLine("}") sb.AppendLine("if (Sys) Sys.Application.add_load(FixMaskedEditExtender);") sb.AppendLine("</script>") Dim l As New LiteralControl(sb.ToString()) Me.Controls.Add(l) End Sub End Class ``` See that there are two lines to remove the ThousandsPlaceholder (because I needed that), you must replace with yours changes. Saludos!

Viewing all articles
Browse latest Browse all 4356

Trending Articles



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