Monday, October 13, 2008

Validation in Updatepanel

I am writing this post about how to use validation controls with asp.net updatepanel control after seeing lots of posts in asp.net forums, Orkut communities of asp.net that their validation controls do not work inside update panel.

To resolve this error, add the tagmapping section in web.config file of your project like this:

<tagMapping>

<add tagType="System.Web.UI.WebControls.CompareValidator"
mappedTagType="Sample.Web.UI.Compatibility.CompareValidator, Validators, Version=1.0.0.0"/>

<add tagType="System.Web.UI.WebControls.CustomValidator"
mappedTagType="Sample.Web.UI.Compatibility.CustomValidator, Validators, Version=1.0.0.0"/>

<add tagType="System.Web.UI.WebControls.RangeValidator"
mappedTagType="Sample.Web.UI.Compatibility.RangeValidator, Validators, Version=1.0.0.0"/>

<add tagType="System.Web.UI.WebControls.RegularExpressionValidator"
mappedTagType="Sample.Web.UI.Compatibility.RegularExpressionValidator, Validators, Version=1.0.0.0"/>

<add tagType="System.Web.UI.WebControls.RequiredFieldValidator"
mappedTagType="Sample.Web.UI.Compatibility.RequiredFieldValidator, Validators, Version=1.0.0.0"/>

<add tagType="System.Web.UI.WebControls.ValidationSummary"
mappedTagType="Sample.Web.UI.Compatibility.ValidationSummary, Validators, Version=1.0.0.0"/>

</tagMapping>

For more information you can refer Scottgu's post Common Gotcha: Validation Controls used within the control and Matt Gibbs post ASP.NET AJAX Validators.

Happy Programming.. ;)

No comments: