Friday, April 27, 2012

Dynamic numeric and null validation for textbox in VB.NET


 Dim txt As New TextBox()
                txt.ID = "txt" & i.ToString()
                txt.MaxLength = 6
                txt.Attributes.Add("onblur", "validate(this);")
                Dim ftext As New AjaxControlToolkit.FilteredTextBoxExtender()
                ftext.TargetControlID = txt.ClientID
                ftext.FilterType = AjaxControlToolkit.FilterTypes.Numbers Or AjaxControlToolkit.FilterTypes.Custom
                ftext.ValidChars = "."
                Dim req As New RequiredFieldValidator()
                req.ID = "req" & i.ToString()
                req.ControlToValidate = txt.ClientID
                req.ErrorMessage = "*"
                req.ForeColor = Drawing.Color.Red
                req.Enabled = True
                req.Visible = True
                req.EnableViewState = True
                req.Display = ValidatorDisplay.Dynamic
                req.ValidationGroup = "rej"

No comments:

Using Authorization with Swagger in ASP.NET Core

 Create Solution like below LoginModel.cs using System.ComponentModel.DataAnnotations; namespace UsingAuthorizationWithSwagger.Models {     ...