0

I have a dropdown that displays nothing. If I hit the save button and nothing is displayed I want an error message stating something has to be selected

I've tried if ddl.POApprover.text = "" then display the message but that doesn't display

If ddlPOApprover.Text = "" And (Session("UserGroup") = 13) Then
            MsgBox("Error: An Approver must be provided before you can save")
            blnValidation = False
        End If

I want the error to come up when I hit save but it doesn't

3
  • I see you are using Session in there. Does that mean it's an ASP.NET program? If so, the message box will appear on the server, which is probably not what you intended. Commented Sep 18, 2019 at 10:18
  • ...but you could use How can I display a messagebox in ASP.NET? Commented Sep 18, 2019 at 10:23
  • Either way, you need to set Option Strict On and correct the problems it points out for you. Commented Sep 20, 2019 at 8:16

2 Answers 2

1

It's If ddlPOApprover.SelectedValue not .Text

Sign up to request clarification or add additional context in comments.

Comments

1

A Combobox has an array from 0 to numberOfItems -1. whenever there is nothing selected, it's index is -1 so you can check if ddlPOApprover.selectedindex < 0 then no item has been chosen

Edit: i also want you to try replacing And with AndAlso like: If ddlPOApprover.Text = "" AndAlso (Session("UserGroup") = 13) Then would it still give you an error? if not then you can choose either my main answer or leave it and just change And to AndAlso

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.