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