Click here to Skip to main content
15,906,097 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can i hide validation summary from code behind in c#.

Means Problem is that:
C#
<asp:ValidationSummary runat="server" ID="ValidationSummary1" ValidationGroup="CheckValidation" />

it is visible on page

Now on button click event i want to hide this validation summary..
And button is inside UpdatePanel where as ValidationSummary is out side UpdatePanel

i try with below code but its not work
C#
ValidationSummary1.ShowSummary = false;

C#
ValidationSummary1.Visible = false;

C#
ValidationSummary1.Style.Add(HtmlTextWriterStyle.Display, "none");

Thanks
Posted

1 solution

Ok, if button is inside update panel i'm assuming your page is not posting back? if so, then why don't you resolve this using javascript/jQuery on client-side?

ASP.NET
<asp:button id="btnId" runat="server" text="Click ME" onclick="btnId_OnClick" onclientclick="HideValidationSummary( $('#ValidationSummary1') );" xmlns:asp="#unknown"></asp:button>


and your jQuery function:
JavaScript
function HideValidationSummary( summaryControl )
{
    $( summaryControl ).hide( );
}


or if you want to use javascript not jQuery
ASP.NET
<asp:button id="btnId" runat="server" text="Click ME" onclick="btnId_OnClick" onclientclick="HideValidationSummary( 'ValidationSummary1' );" xmlns:asp="#unknown"></asp:button>


and your javascript function:
JavaScript
function HideValidationSummary( summaryControl )
{
    document.getElementById( summaryControl ).style.display = 'none';
}


Good luck,
Morgs
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900