By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,534 Members | 1,830 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,534 IT Pros & Developers. It's quick & easy.

Does .Net allow a ValidationSummary control to be added from code?

P: n/a
I'm trying to add a ValidationSummary control to a common base page used by
all of our system's aspx/ascx files. The base page is a regular class file
that inherits from System.Web.UI.Page. When I debug the application and click
the submit button with a data element that fails a validation, I get the
correct ValidationSummary messageBox, but I then receive the following error
in WebUIValidation.js ValidationSummaryOnSubmit():

Microsoft JScript runtime error: 'style' is null or not an object.

The line that causes the error is: summary.style.display = "none";

I didn't think the ValidationSummary class had a style attribute, but this
same line of code does not cause an error if I add the ValidationSummary
directly to the aspx/ascx page by dragging it from the Toolbox.

In the base page, the following code adds the ValidationSummary control:

System.Web.UI.WebControls.ValidationSummary validationSummary1;
validationSummary1 = new System.Web.UI.WebControls.ValidationSummary();
validationSummary1.ID = "validationSummary1";
validationSummary1.ShowMessageBox = true;
validationSummary1.ShowSummary = true;
form.Controls.AddAt(0,validationSummary1);

--
Any help would be much appreciated!

Regards.
Nov 22 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.