Scenario: We have a DropDownList which has an item called ‘Other’. We want to have a text box that becomes visible when the user makes that choice.
In ASP.net, we perform an action based on an event. For instance – if we have a textbox that we want in visible until we say otherwise, then, we add code to an event handler, or the tag so that:
Then, based on a control’s event (like a button click or a DropDowList’s SelectedIndexChanged event), we make the textbox visible:
However, in InfoPath, thogh the same thing is generally possible, the way in which you look at things is a little different – going at it from a negative perspective.
In the same scenario, instead, we’d right click on the textbox and choose ‘Conditional Formatting’. Next, we’d add a new condition. From the dialog that pops up, (in the ‘If this condition is true’ section) in the first dropdown, we’d choose the DropDownList with ‘Other’ as an item. In the next dropdown, we’d choose ‘is not equal to’, and next, we’d type in the word ‘Other’. Then, we’d select the checkbox for ‘Hide This Control’. Or, you could choose ‘Read Only’ or a few other formatting options.
(Just so you’ll know, ‘Hide this control’ is not available when you are trying to do the same thing with a DatePicker control, but ‘Read Only’ is available for a work-around.)
All Things DotNet Discussed – Winforms/ASP.Net/SharePoint/WPF