• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 680
  • Last Modified:

Validation Summary additions

I want to put my validation summary around some HTMl that i have built for the validation summary.

How do i customize the smmary to show inside this HTML, or more importantly to hide and show to html containing it...

<table> <----- Want to hide and show this table with the validation summary.
<asp:ValidationSummary ID="ErrSummary" HeaderText="The following errors occured:"
ShowSummary="true" DisplayMode="BulletList" runat="server" />

Any help would be great,
1 Solution
Whenever I ask the Visual Desiger at work about these requests he usually uses custom rolled JavaScript to hide elements like tables, or he places controls inside of a <DIV> and sets the visibility there.
you can set CssClass and set Display=None to hide the entire validation summary

or you can modifie your ErrorMessage like

ErrorMessage="<B>" + ErrorMessage
then add above ErrorMessage in you customValidator control

Suppose you have a form with some input fields, validators and a submit button:

        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /><br />

and then you have your validation summary, enclosed in some table:

                <td><asp:ValidationSummary ID="ValidationSummary1" runat="server" /></td>

1) Make the table run on the server & set it's style to display:none, like this:
<table runat="server" ID="ValSumTable" style="display:none">

We're doing this so a) we have an id for the table and b) we can reference it from the server-side code

2) Add this code to your Page_Load:

                  "document.getElementById('" + ValSumTable.ClientID + "').style.display = Page_IsValid ? 'none' : '';");

This adds a small script to run after the validation but before the submit. It will show/hide the table, together with the validation summary.

3) Add this to the Button1_OnClick (submit) event:

            ValSumTable.Style["display"] = Page.IsValid ? "none" : "";

This is necessary in case the client-script validation is disabled.
NugsAuthor Commented:
Awesome, thank you very much...

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now