How do I require a value in a textbox in a Wix custom dialog?

一个人想着一个人 提交于 2020-01-13 08:22:08

问题


I have a Wix dialog with a control of type edit (which is a uri of a server the service depends on).

How can I disable the Next button until a value has been input?


回答1:


Here's an excerpt from some (old) production code we used to use:

<Dialog Id="MyDlg_Error" Width="260" Height="85" NoMinimize="yes" Title="!(loc.MyDlg_Title)">
    <Control Id="MyDlgSkipDesc" Type="Text" Width="194" X="48" Y="15" Height="30" Text="!(loc.MyDlg_ErrorMsg)" />
    <Control Id="Ok" Type="PushButton" X="97" Y="57" Width="66" Height="17" Text="!(loc.WixUIOK)" />
</Dialog>

<Publish Dialog="MyDlg" Control="Next" Event="SpawnDialog" Value="MyDlg_Error"><![CDATA[Not (MY_REQUIRED_FIELD <> "")]]></Publish>

<Publish Dialog="MyDlg_Error" Control="Ok" Event="EndDialog" Value="Return">1</Publish>



回答2:


There's no reasonable way to do that. Instead, leave Next enabled and do your check with a SpawnDialog control event tied to Next that shows an error if the property is empty. It also lets you run a validation custom action if you want something more useful that "not empty."



来源:https://stackoverflow.com/questions/5533736/how-do-i-require-a-value-in-a-textbox-in-a-wix-custom-dialog

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!