Congratulations to all monthly winners of May 2013 !!! They have won INR 2900 cash and INR 27497 worth prize.
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 16479 |  Welcome, Guest!   Register  Login
 Home > Forums > ASP.NET > Validation Summary in ASP.NET ...
.Netlearner

Validation Summary in ASP.NET

Replies: 3 | Posted by: .Netlearner on 8/14/2012 | Category: ASP.NET Forums | Views: 1374 | Status: [Member] | Points: 10  


Hello all,
Instead of displaying Each Seperate Regular Expression Validator Can we display The Error messages in validation summary.How this can be done


Reply | Reply with attachment | Alert Moderator

 Responses below this adGet hundreds of .NET Tips and Tricks videos

 Replies

Ranjeet_8
Ranjeet_8  
Posted on: 8/14/2012 8:18:02 AM
Level: Gold | Status: [Member] | Points: 25

Try this

<asp:TextBox ID="txtName" runat="server" MaxLength="80" ></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1"
ControlToValidate="txtName"
runat="server" ErrorMessage="Enter your name" Display="None"
SetFocusOnError="true">
</asp:RequiredFieldValidator>

<asp:TextBox ID="txtEmailID" runat="server" MaxLength="100" ></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2"
ControlToValidate="txtEmailID"
runat="server" ErrorMessage="Enter your email id" Display="None"
SetFocusOnError="true">
</asp:RequiredFieldValidator>




<asp:ValidationSummary ID="ValidationSummary1" runat="server" ShowMessageBox="true"
ShowSummary="false" />

OR
Refer this url
http://www.dotnetfunda.com/codes/code3016-how-to-use-validation-summary.aspx

.

.Netlearner, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

San.Pblr.Gct
San.Pblr.Gct  
Posted on: 8/14/2012 8:37:08 AM
Level: Starter | Status: [Member] | Points: 25

If you already have individual validations, set Text of validationcontrol="*"

Like this

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>  

<asp:RequiredFieldValidator
ID="RequiredFieldValidator1"
runat="server"
ControlToValidate="TextBox1"
ErrorMessage='Input Country!'
EnableClientScript="true"
SetFocusOnError="true"
Text="*"
>
</asp:RequiredFieldValidator>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator
ID="RequiredFieldValidator2"
runat="server"
ControlToValidate="TextBox2"
ErrorMessage='Input Region!'
EnableClientScript="true"
SetFocusOnError="true"
Text="*"
>
</asp:RequiredFieldValidator>


Then add validationsummarycontrol.

  <asp:ValidationSummary ID="ValidationSummary1" runat="server" HeaderText="Following error occurs:" ShowMessageBox="false" DisplayMode="BulletList" ShowSummary="true" />  

.Netlearner, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Srilu.Nayini577
Srilu.Nayini577  
Posted on: 8/14/2012 9:44:18 AM
Level: Starter | Status: [Member] | Points: 25

we can write both above two codes.It works fine.
So you can use any of the above two approaches.

Thank you,

SRILATHA
.Net Developer

.Netlearner, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Reply - Please login to reply


Click here to login & reply

Found interesting? Add this to:


 Latest Posts

Write New Post | More ...

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 6/19/2013 7:14:09 PM