How do I write code to check for empty drop-down list box

Posted on 2008-11-19
Last Modified: 2012-08-14
Hi there,
I need to verify that a value has been entered into a drop down box on my infopath form. I am brand new to infopath and c# so please excuse my ignorance.

What i have is a button that submits drop down/text box values to a sharepoint list. I have tried to use the standard 'Data Validation' on the drop down fields themselves, but the c# code executes first before the built in 'Data Validation' goes to check the value.

Basically I need an example of c# syntax in infopath that will check for a null value in the drop down boxes.
Here is some pseudocode of what im after

if (dropdown1 is empty) then
stop executing code and set focus to dropdown1
process rest of code

if anyone could provide an example that would be great.

Question by:cscb08
    LVL 28

    Accepted Solution

    You could hide or disable the button, so that it is not clickable until the dropdown has a value.  That is typically what i do.

    Author Comment

    Hi clayfox. Cheerss for that. I have found the solution, I was able to find some example c# code that now works.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    Before you can digitally sign infopath forms, you must have a digital certificate. Microsoft Certificate Services will need to be enabled on a Windows Server 2008 to facilitate the creation and verification of the digital certifciates on the web ser…
    Local Continuous Replication is a cost effective and quick way of backing up Exchange server data. The following article describes the steps required to configure Local Continuous Replication. Also, the article tells you how to restore from a backup…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now