A Tip for a MaskedEditExtenders Issue in Web Applications

(This post was written by Application Developer Aaron Olson)

Today I came across an odd issue. We are building a web application for a client of ours. We have a number of controls on the page that are utilizing the ajaxcontroltoolkit’s MaskedEditExtender.

The Issue: When we would load the form with existing data, we would notice that certain controls’ textchanged events were firing. This was causing us some heart ache as when this event gets fired, we have flags in the bound object that get set, erroneously telling the application changes had occurred. Later down the line this caused some updating where updating was not necessary as nothing had really changed within the object.

Our Findings: I did a bit of research on this issue and couldn’t find a whole lot on it. When I thought about it a little further and examined the data we were filling the control with, I remember that the way the data is being stored within SQL is different than the way we are portraying it on the screen. So, for example, a social security number within SQL was being stored like so, 123456789.  When we fill the textbox with the data in this format, once the form is done loading, the MaskedEditExtenders client side java says, hold on cowboy, this data has not been formatted and formats the text kicking off the event.

Resolution:  I created a process extension to properly format a string, which I then fed into the textbox on load. This way the data I am filling into the textbox is already formatted properly, preventing the textchanged event from firing.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s