עבור לתוכן
View in the app

A better way to browse. Learn more.

HWzone

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

עזרה בכתיבת ולידטור ל CheckBoxList ב ASP.NET 1.1

Featured Replies

פורסם

הי אני מנסה ליצור ולידאטור ל CheckBoxList שיקבל כפרמטר איזה סוג ואלידציאה, האם חובה לסמן n אופציות או לחילופין חובה לסמן עד n אופציות וכמובן פרמטר המציין כמה פריטים לסימון כלומר את ה n

הבעיה שלי שהוא זורק הודעת שגיאה לגבי ה ControlToValidate שלא יכול לקבל את ה CheckBoxList

אודה לעזרתכם בנידון כמו כן חשוב לי לציין שמדובר על קוד ב .NET גרסה 1.1 ולא 2 ואני חייב שזה ישאר כך.



Imports System
Imports System.Web.UI
Imports System.Web.UI.WebControls

Public Class CheckBoxListValidator
Inherits BaseValidator
Enum ValidationLogicOptions
Exacty
Upto
End Enum
Dim _ValidationLogic As ValidationLogicOptions
Dim _ItemsToSelect As Integer

Public Property ItemsToSelect() As Integer
Get
Return _ItemsToSelect
End Get
Set(ByVal Value As Integer)
_ItemsToSelect = Value
End Set
End Property

Public Property ValidationLogic() As ValidationLogicOptions
Get
Return _ValidationLogic
End Get
Set(ByVal Value As ValidationLogicOptions)
_ValidationLogic = Value
End Set
End Property
Protected Overrides Function EvaluateIsValid() As Boolean

Dim chkList As CheckBoxList = Me.FindControl(Me.ControlToValidate)
Dim count As Integer = 0
Dim Valid As Boolean = False
For Each chk As CheckBox In chkList.Items
If chk.Checked = True Then
If count >= 0 And count <= _ItemsToSelect Then
count = count + 1
End If
End If
Next
Select Case _ValidationLogic
Case ValidationLogicOptions.Exacty
If count = _ItemsToSelect Then
Valid = True
Else
Valid = False
End If

Case ValidationLogicOptions.Upto
If count <= _ItemsToSelect Then
Valid = True
Else
Valid = False
End If
End Select

Return Valid

End Function

End Class

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.