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"