ASP.NET RequiredField RegularExpression Triggering After Page Postback

Last Reply 6 months ago By pandeyism

Posted 6 months ago

Sir,

In my registration i am having around 10 fields as textbox dropdownlist and fileupload and also a submit button. When I click on submit button the validations are not triggering also page is posting back and then validations getting triggered. why.

I have used Master page and used Toolscriptmanager for ajax calendar.

You are viewing reply posted by: pandeyism 6 months ago.
Posted 6 months ago Modified on 6 months ago

Hi  Sumeet,

I checke your code is validation for all control except dropdowlist. so for validation dropdownlist replcae below code with your code.

You need to add below line of code.

dropdownclassrecoganized.Items.Add(New ListItem("--Select--", "0"))

Code

Public Sub loadclassrecog()
    Dim i As Integer = 0
    dropdownclassrecoganized.Items.Clear()
    dropdownclassrecoganized.Items.Add(New ListItem("--Select--", "0"))
    Using con As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("constr").ConnectionString)
        Using cmd As SqlCommand = New SqlCommand("Select * from Customers", con)
            con.Open()
            Dim dr As SqlDataReader = cmd.ExecuteReader()
            While dr.Read()
                i += 1
                dropdownclassrecoganized.Items.Add(dr("Name").ToString())
                dropdownclassrecoganized.Items(i).Value = dr("CustomerId").ToString()
            End While
            con.Close()
        End Using
    End Using
End Sub