Lance
Lance

Reputation: 23

Controlling Next Button State in Wix Installer

I'm new to using Wix Installer and I'm having some problems trying to control a Next button I have on one of my dialogs. I've asked this question on the Wix Mailing List, but didn't get an answer, so I'm trying here. I took WixUI_Mondo.wxs and renamed it as well as modified it to include a dialog for checking a database connection. Below is a snippet of my modified WixUI_Mondo.wxs:

<Publish Dialog="CheckDbConnectionDlg" Control="Next" Event="NewDialog"
Value=VerifyReadyDlg">1</Publish>
<Publish Dialog="CheckDbConnectionDlg" Control="Back" Event="NewDialog"
Value=WelcomeDlg">2</Publish>

Now within my CheckDbConnectionDlg.wxs I have a Next button that I'm trying to control it's Enabled state via a property I set within a CustomAction. Below is a snippet of my CheckDbConnectionDlg.wxs with the Next button I'm trying to control.

<Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17"
Text="Next">
      <Condition Action="disable">
           <![CDATA[CONTINUE <> "True]]>
      </Condition>
      <Condition Action="enable">
           CONTINUE ="True"
      </Condition>
</Control>

Here is my custom action where I'm setting the property:

[CustomAction]
public static ActionResult TestSqlConnection(Session testSession)
{
     ...
     ...
     ...
     //If the connection is successful
     testSession["CONTINUE"] = "True";

      // Else set the session to False
     testSession["CONTINUE"] = "False";
}

And my Product.wxs

<UIRef Id="WixUI_CustomUI" />

<Binary Id="SqlCustomAction" SourceFile="SqlCustomAction.CA.dll" />
<CustomAction Id=CA_testSqlConnection" BinaryKey="SqlCustomAction"
DllEntry="TestSqlConnection" Execute="immediate" Return="check" />

<InstallUISequence>
   <Custom Action="CA_testSqlConnection" After="ExecuteAction" />
</InstallUISequence>

What happens is that when I get to the CheckDbConnectionDlg the Next button is disabled as I want it to be, on that dialog I have a button that tests a connection to a database and if it's good, I want the Next button to be enabled so installation can proceed; otherwise, I want it to stay disabled. If the connection succeeds it's not enabling the Next button, but it does if I click Back and then Next.

Can someone tell me how to correct this?

Upvotes: 2

Views: 5167

Answers (1)

Christopher Painter
Christopher Painter

Reputation: 55581

This is a limitation of Windows Installer. It isn't really event driven. Conditions are only evaluated when you go from dialog to dialog not when something happens within the dialog. The standard workaround is to have conditions on the Control Events instead to prvent transition to the next dialog.

Upvotes: 1

Related Questions