![]() |
| |||||||
| Sponsored Links |
![]() | « Previous Thread | Next Thread » |
| | LinkBack | Thread Tools | Display Modes |
|
#1
| ||||
| ||||
| I had an instance where I wanted to simply set off ASP.Net's ValidationSummary control to display an error to the user instead of creating another element to handle this. After some research, I came across the IValidator class. Code: Imports System.Web.UI
Public Class ValidationError
Implements IValidator
Private _errorMessage As String = String.Empty
Private _isValid As Boolean = False
Public Shared Sub Display(ByVal message As String)
Dim currentPage As Page = TryCast(HttpContext.Current.Handler, Page)
currentPage.Validators.Add(New ValidationError(message))
End Sub
Public Sub New(ByVal message As String)
ErrorMessage = message
IsValid = False
End Sub
Public Property ErrorMessage() As String Implements System.Web.UI.IValidator.ErrorMessage
Get
Return _errorMessage
End Get
Set(ByVal value As String)
_errorMessage = value
End Set
End Property
Public Property IsValid() As Boolean Implements System.Web.UI.IValidator.IsValid
Get
Return _isValid
End Get
Set(ByVal value As Boolean)
_isValid = value
End Set
End Property
Public Sub Validate() Implements System.Web.UI.IValidator.Validate
End Sub
End Class
Code: Page.Validate()
ValidationError.Display("Place error message here")
__________________ jmurrayhead If you agree with me... click the icon! If my post solved your problem, click the button in the lower right-hand corner of the post.Join our Folding team: DeveloperBarn Folding |
| Sponsored Links |
![]() |
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| validation | todd2006 | JavaScript Programming | 5 | July 30th, 2008 09:23 AM |
| How do you add a static item to a dynamic dropdownlist | Shem | .Net Development | 19 | July 4th, 2008 08:14 AM |
| textbox validation | todd2006 | JavaScript Programming | 6 | July 2nd, 2008 01:30 PM |
| [ASP.Net/VB.Net] Programmatically Select Item in ListBox or DropDownList | jmurrayhead | Code Samples | 0 | June 27th, 2008 10:05 AM |
| Loop / Summary help | Rebelle | ASP Development | 7 | April 11th, 2008 10:12 AM |