CheckBoxes list problem

tiffany

Well-known member
Joined
Aug 7, 2005
Messages
57
Programming Experience
1-3
Hi recently i had a problem about checkboxes lists in webform. I tried to validate the checkboxes list if it is unclicked and pop up a alert box. I input the codes as follows:


If (CheckBoxList1.SelectedValue = False) Then

ShowMessage("Branch(es) are required")

End If

Private Sub ShowMessage(ByVal message As String)

Dim scriptString As String = "<script language=JavaScript>"

scriptString += "alert('" + message + "');"

scriptString += "</script>"

Page.RegisterStartupScript("ShowMessage", scriptString)

End Sub

But there an error show "Input string was not in a correct format. " when i tried to run the program. Can anyone help me solve the problem? thankx.
 
The .SelectedValue for CheckBoxList returns a string, not a boolean.
Try this:

If (CheckBoxList1.SelectedValue = String.Empty) Then

ShowMessage("Branch(es) are required")

End If

HTH

Blokz
 
Back
Top