Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sub class of validationsummary control
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00797294
Message ID:
00797328
Vues:
19
Hi Randy,

Here is the conversion. The message you received is standard for converters to post. They just want to make sure the Validate method is part of your class. In the sample code you already have the method so you should be fine with the conversion.
Imports System
Imports System.Web.UI
Imports 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
      Inherits 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 Sub AddErrorMessage(msg As String)
         Me.Page.Validators.Add(New DummyValidator(msg))
      End Sub 'AddErrorMessage
   End Class 'ValidationSummary
   
   '/ <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> 
   
   Friend Class DummyValidator
      Implements IValidator 
      
      Private errorMsg As String
      
      
      Public Sub New(msg As String)
         errorMsg = msg
      End Sub 'New
      
      
      Public Property ErrorMessage() As String
         Get
            Return errorMsg
         End Get
         Set
            errorMsg = value
         End Set
      End Property 
      
      Public Property IsValid() As Boolean
         Get
            Return False
         End Get
         Set
         End Set
      End Property
       
      Public Sub Validate()
      End Sub 'Validate
   End Class 'DummyValidator
End Namespace 'Juranek.Web.Controls
>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() {
>		}
>	}
>}
>
>
-----------------------------------------

Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.com
www.prenia.com
Weblog: blogs.prenia.com/cathi
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform