2

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?

Lance
  • 23
  • 1
  • 3

1 Answers1

1

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.

Christopher Painter
  • 54,556
  • 6
  • 63
  • 100
  • I have a condition already, but it's based on the condition being set within my customaction. Is there another way I can refactor the code above to work properly? – Lance Jan 24 '11 at 11:48
  • Putting a Condition on a Control Element results in a row in the ControlCondition table. This is the limitation of MSI part I'm talking about. Instead put the condition on the PublishElement as this results in a row in the ControlEvent table. You won't be able to Enable/Disable the control but you will be able to prevent it from going to the next dialog. – Christopher Painter Jan 24 '11 at 12:23
  • 1
    Take a look at the solution provided by @Daniel Powell on this post [link](http://stackoverflow.com/questions/4241863/wix-interactions-with-conditions-properties-custom-actions) – bigfoot Nov 02 '11 at 12:47