[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Validation Summary additions

Posted on 2007-10-20
4
Medium Priority
?
676 Views
Last Modified: 2010-07-27
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.
  <tr>
    <td>
<asp:ValidationSummary ID="ErrSummary" HeaderText="The following errors occured:"
ShowSummary="true" DisplayMode="BulletList" runat="server" />
    </td>
  </tr>
</table>

Any help would be great,
Nugs
0
Comment
Question by:Nugs
4 Comments
 
LVL 8

Expert Comment

by:davecorun
ID: 20116646
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.
0
 
LVL 10

Expert Comment

by:SystemExpert
ID: 20117130
Hi
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

Thanks
0
 
LVL 5

Accepted Solution

by:
discon0 earned 2000 total points
ID: 20117540
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:

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

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:

            ClientScript.RegisterOnSubmitStatement(this.GetType(),
                  "ClientShowHideSummary",
                  "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.
0
 
LVL 2

Author Comment

by:Nugs
ID: 20118393
Awesome, thank you very much...

Nugs
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question