I have a task of displaying Validation summery Message header in diffrent style and font.I have mentioned the code below.
for Ex I left the Bank Name Field then press Nex button the Error Message show show as below. Can any one solve this issue.
Create was unsuccessful. Please correct the errors and try again.------>Header below the header. this Header Message show in different style.
* Enter the Bank Name
Model.
public class
IRSPayment : EntityBase
{
[XmlAttribute()]
public long IRSPaymentId {
get; set; }
[XmlAttribute()]
public long IRSPaymentOptionId {
get; set; }
[XmlAttribute()]
public string BankName {
get; set; }
[XmlAttribute()]
[
RegularExpression(@"(01|02|03|04|05|06|07|08|09|10|11|12|21|22|23|24|25|26|27|28|29|30|31|32)[0-9]{7}", ErrorMessage =
"<br />Bank Routing Number is invalid.")]
public string RTN {
get; set; }
public string AccountNumber {
get; set; }
[XmlAttribute()]
public bool IsEROPin {
get; set; }
[XmlAttribute()]
public int EFWPin {
get; set; }
[XmlElement()]
public Form7004 Form7004 {
get; set; }
[XmlAttribute()]
public decimal Amount {
get; set; }
[XmlAttribute()]
public long AccountTypeID {
get; set; }
[XmlAttribute()]
public DateTime PaymentDate {
get; set; }
[XmlIgnore()]
public List<AccountType> ListAccountType {
get; set; }
[XmlAttribute()]
public byte[] Form8878A {
get; set; }
[XmlAttribute()]
public string FileName {
get; set; }
[XmlAttribute()]
public string FileExtension {
get; set; }
public List<ErrorInfo> GetRuleViolations()
{
var validationIssues =
new List<ErrorInfo>();
if (IRSPaymentOptionId == (long)IRSPaymentOptionEnum.EFW)
{
if (string.IsNullOrEmpty(BankName))
{
validationIssues.Add(new
ErrorInfo("BankName",
"Enter the Bank Name.",
this));
}
if (string.IsNullOrEmpty(RTN))
{
validationIssues.Add(new
ErrorInfo("RTN",
"Enter the RTN.",
this));
suresh_dotne...
Member
8 Points
188 Posts
show Validation Summery Message Header in diffrent style
Jun 17, 2009 07:46 AM|LINK
Hi:
I have a task of displaying Validation summery Message header in diffrent style and font.I have mentioned the code below.
for Ex I left the Bank Name Field then press Nex button the Error Message show show as below. Can any one solve this issue.
Create was unsuccessful. Please correct the errors and try again.------>Header below the header. this Header Message show in different style.
* Enter the Bank Name
Model.
public class IRSPayment : EntityBase
{
[XmlAttribute()] public long IRSPaymentId { get; set; } [XmlAttribute()] public long IRSPaymentOptionId { get; set; } [XmlAttribute()] public string BankName { get; set; } [XmlAttribute()][
RegularExpression(@"(01|02|03|04|05|06|07|08|09|10|11|12|21|22|23|24|25|26|27|28|29|30|31|32)[0-9]{7}", ErrorMessage = "<br />Bank Routing Number is invalid.")] public string RTN { get; set; } public string AccountNumber { get; set; } [XmlAttribute()] public bool IsEROPin { get; set; } [XmlAttribute()] public int EFWPin { get; set; } [XmlElement()] public Form7004 Form7004 { get; set; } [XmlAttribute()] public decimal Amount { get; set; } [XmlAttribute()] public long AccountTypeID { get; set; } [XmlAttribute()] public DateTime PaymentDate { get; set; } [XmlIgnore()] public List<AccountType> ListAccountType { get; set; } [XmlAttribute()] public byte[] Form8878A { get; set; } [XmlAttribute()] public string FileName { get; set; } [XmlAttribute()] public string FileExtension { get; set; } public List<ErrorInfo> GetRuleViolations(){
var validationIssues = new List<ErrorInfo>();
if (IRSPaymentOptionId == (long)IRSPaymentOptionEnum.EFW){
if (string.IsNullOrEmpty(BankName)){
validationIssues.Add(new ErrorInfo("BankName", "Enter the Bank Name.", this));}
if (string.IsNullOrEmpty(RTN)){
validationIssues.Add(new ErrorInfo("RTN", "Enter the RTN.", this));}
if (PaymentDate == null || (PaymentDate != null && PaymentDate == DateTime.MinValue)){
validationIssues.Add(new ErrorInfo("PaymentDate", "Enter the Payment Date.", this));}
if (PaymentDate != null && PaymentDate != DateTime.MinValue && PaymentDate < DateTime.Now){
validationIssues.Add(new ErrorInfo("PaymentDate", "Payment Date cannot be a past date.", this));}
if (EFWPin <= 0 || EFWPin.ToString().Length < 5){
validationIssues.Add(new ErrorInfo("EFWPin", "Enter the EFW Pin.", this));}
if (AccountNumber == null || Convert.ToInt32(AccountNumber.Trim().Length) < 5){
validationIssues.Add(new ErrorInfo("AccountNumber", "Enter the Bank Account Number.", this));}
bool _isNumeric = IsNumeric(AccountNumber);if (!_isNumeric){
validationIssues.Add(new ErrorInfo("AccountNumber", "AccountNumber is Not Valid Please give Account Number with out special characters.", this));}
}
// Validate attributes validationIssues.AddRange(DataAnnotationsValidationRunner.GetErrors(this)); return validationIssues;}
#region Check Numeric /// <summary> /// Determines whether the specified value is numeric. /// </summary> /// <param name="value">The value.</param> /// <returns> /// <c>true</c> if the specified value is numeric; otherwise, <c>false</c>. /// </returns> private bool IsNumeric(string AccountNumber){
Regex regex = new Regex(@"(^[0-9]*$)");if (regex.IsMatch(AccountNumber)){
return true;}
else{
return false;}
}
#endregion
public void Validate(){
var validationIssues = GetRuleViolations(); if (validationIssues.Count > 0) throw new RulesException(validationIssues);}
}
IRSPaymet.aspx page:
<%
= Html.ValidationSummary()%></p>
"ASP.NET MVC 1.0"
Dave_Winches...
Contributor
3051 Points
716 Posts
Re: show Validation Summery Message Header in diffrent style
Jun 17, 2009 07:57 AM|LINK
Hi
You can change the header like this by inserting some html or by add a CssClass to your ValidationSummary:
Hope this helps.
Dave
Please mark as ANSWER if this is the solution.
Augi
Contributor
6730 Points
1142 Posts
Re: show Validation Summery Message Header in diffrent style
Jun 17, 2009 07:58 AM|LINK
You have to change "validation-summary-errors" CSS class definition in your Site.css file.
rtpHarry
All-Star
56620 Points
8958 Posts
Re: show Validation Summery Message Header in diffrent style
Jun 17, 2009 07:59 AM|LINK
Looks like the code formatter messed this up...
Should be:
<asp:ValidationSummary ID="ValidationSummary1" runat="server" DisplayMode="BulletList" HeaderText="<h3><span>What's going on?</span></h3>" CssClass="error" />Augi
Contributor
6730 Points
1142 Posts
Re: show Validation Summery Message Header in diffrent style
Jun 17, 2009 08:57 AM|LINK
Harry, Dave, we are here in ASP.NET MVC forum, not ASP.NET WebForms forum [;)]
Dave_Winches...
Contributor
3051 Points
716 Posts
Re: show Validation Summery Message Header in diffrent style
Jun 17, 2009 09:24 AM|LINK
Ooops! Sorry - Did not notice.
Please mark as ANSWER if this is the solution.
sunilsingh
Member
132 Points
64 Posts
Re: show Validation Summery Message Header in diffrent style
Jun 17, 2009 02:19 PM|LINK
Hi
To show the validation summary message header in different style
1 : Open site.css file of your application in Content folder
2. goto .validation-summary-errors.
3. Here you can change the style of the message.
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
If you think you had found the answer then
Mark this as Answer
SunilSingh
Remember to click Mark as Answer on the post that helps to others.