Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sub class of validationsummary control
Message
De
06/06/2003 11:23:50
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
Sub class of validationsummary control
Divers
Thread ID:
00797294
Message ID:
00797294
Vues:
67
this should be useful for everyone. it is a subclass of the validationsummary control that allows u to add your own error messages. this means the validation control doesn't have to have another validation control on the web form. i need a little help converting it to vb and how to implement it on the web form. Any takers. Thanks.

as far as converting, i tried a website thats converts c# to vb , but got the following message.

Friend Class DummyValidator
Implements IValidator 'ToDo: Add Implements Clauses for implementation methods of these interface(s)
using System;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Juranek.Web.Controls
{
	/// <summary>
	/// This control inheirits the ASP.NET ValidationSummary control but adds
	/// the ability to dynamically add error messages without requiring 
	/// validation controls.
	/// </summary>
	/// <author>Scott Juranek</author>
	/// <remarks>3/4/2002: Original Implementation</remarks>
	public class ValidationSummary : System.Web.UI.WebControls.ValidationSummary
	{
		/// <summary>
		/// Allows the caller to place custom text messages inside the validation
		/// summary control
		/// </summary>
		/// <param name="msg">The message you want to appear in the summary</param>
		public void AddErrorMessage(string msg) {
			this.Page.Validators.Add(new DummyValidator(msg));
		}
	}

	/// <summary>
	/// The validation summary control works by iterating over the Page.Validators
	/// collection and displaying the ErrorMessage property of each validator
	/// that return false for the IsValid() property.  This class will act 
	/// like all the other validators except it always is invalid and thus the ErrorMessage
	/// property will always be displayed.
	/// </summary>
	/// <author>Scott Juranek</author>
	/// <remarks>3/4/2002: Original Implementation</remarks> 
	internal class DummyValidator : IValidator {

		private string errorMsg;

		public DummyValidator(string msg) {
			errorMsg = msg;
		}

		public string ErrorMessage{
			get{ return errorMsg;}
			set{ errorMsg = value;}
		}

		public bool IsValid{
			get{return false;}
			set{}
		}

		public void Validate() {
		}
	}
}
Randy Belcher
AFG Industries, Inc.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform