Unfortunately this cannot be done with a logical If/Else statement. The problem is that the test displays the dialog before it enters the If/Else statement. The Dialog Handler isn't created until the branch is made and since the dialog is displayed before the dialog handler is created, it will never know that the dialog exists. To overcome this, please see this article
on "Conditional Dialog Handling" and let me know if you need further assistance on this.
the Telerik team