SQL Server administration and T-SQL development, Web Programming with ASP.NET and Javascript, SAP Smartforms and ABAP Programming, Windows 7, Visual Studio and MS Office software Kodyaz Development Resources
Development resources, articles, tutorials, samples, codes and tools for .Net, SQL Server, Vista, etc.

Software Development



MaskedEditValidator control NullReferenceException at TextBox Target = (TextBox)MaskExt.FindControl(ControlToValidate);

Hi,

If you are playing around with the AjaxControlToolkit controls and extenders, you might have experienced the following NullReferenceException error with the MaskedEditValidator Ajax control extender:


{"Object reference not set to an instance of an object."}

or in detail;


System.NullReferenceException was unhandled by user code
Message="Object reference not set to an instance of an object."
Source="AjaxControlToolkit"
StackTrace:
at AjaxControlToolkit.MaskedEditValidator.OnPreRender(EventArgs e)
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException:


Actually, the problem or the error occurs when the ControlExtender property of the MaskedEditValidator control is left unset to the related MaskedEditExtender control Id.

Here is a sample which causes the build error above:


<cc1:MaskedEditValidator ID="MaskedEditValidator1" runat="server"
ControlToValidate="TextBox2" Display="Dynamic" EmptyValueBlurredText="*"
EmptyValueMessage="Date is required" InvalidValueBlurredMessage="*"
InvalidValueMessage="Date is invalid" ToolTip="Input a date"
ValidationGroup="MKE"></cc1:MaskedEditValidator>

And if you add the

ControlExtender="TextBox2_MaskedEditExtender"


in order to complete the settings for the MaskedEditValidator


<cc1:MaskedEditValidator ID="MaskedEditValidator1" runat="server"
ControlToValidate="TextBox2" Display="Dynamic" EmptyValueBlurredText="Empty Date"
EmptyValueMessage="Date is required" InvalidValueBlurredMessage="Invalid Date"
InvalidValueMessage="Date is invalid" ToolTip="Input a date"
ValidationGroup="MKE"
ControlExtender="TextBox2_MaskedEditExtender"></cc1:MaskedEditValidator>


Then the problem is solved.

I have made this mistake to set the ControlExtender property. So that is a simple solution :)


Technorati Profile | Add to Technorati Favorites

Published Thursday, December 13, 2007 11:23 AM
Filed Under: ,

Comments

No Comments
Anonymous comments are disabled

About eralper

Worked with Vignette , developed Tcl/Tk
Copyright © 2004 - 2012 Eralper Yilmaz. All rights reserved.
Community Server, by Telligent Systems