SharePoint - How to disable submit Option in View2 !!

Asked By Mohan B on 11-Dec-08 05:06 AM
 Hi !!

I have one Problem in Infopath... in my browser-enabled Infopath template i have two views(view1,view2)
i want to show the submit option in view1 but not in View2.

is it possible to disable the submit option in View2!!!

Thanks & Regards
Mohan

TRY THIS - C_A P replied to Mohan B on 12-Dec-08 02:02 AM

TRY CONDITIONAL FORMATTING TO DISABLE SUBMIT BUTTON ON VIEW2

TRY THIS - C_A P replied to Mohan B on 12-Dec-08 02:04 AM

Solution

Use code to programmatically set the value of another control that will trigger Conditional Formatting on the control that you want to disable/enable.
Discussion

You can accomplish this functionality as follows:

   1. Add a Drop-Down List Box control, a Check Box control, and two Button controls to an InfoPath form template.
   2. Double-click the Check Box control to open its Properties dialog box.
   3. On the Data tab, in the Field name field type isControlEnabled, select 0 for Value when cleared and 1 for Value when checked, and click OK.
   4. Double-click the Drop-Down List Box control to open its Properties dialog box.
   5. On the Display tab, click Conditional Formatting.
   6. On the Conditional Formatting dialog box, click Add.
   7. On the Conditional Format dialog box, select isControlEnabled from the first drop-down list box, leave is equal to in the second drop-down list box, select "0" from the third drop-down list box, tick Disable this control, and click OK.
   8. Click OK on all the dialog boxes that are currently open.
   9. Double-click the first Button control to open its Properties dialog box.
  10. On the General tab, in the Label field type Disable, and then click Edit Form Code to add a Clicked event handler for the button.
  11. Add the following code to the Clicked event handler for the Disable Button control: MainDataSource.CreateNavigator().SelectSingleNode("//my:isControlEnabled", NamespaceManager).SetValue("0");
  12. Double-click the second Button control to open its Properties dialog box.
  13. On the General tab, in the Label field type Enable, and then click Edit Form Code to add a Clicked event handler for the button.
  14. Add the following code to the Clicked event handler for the Enable Button control: MainDataSource.CreateNavigator().SelectSingleNode("//my:isControlEnabled", NamespaceManager).SetValue("1");
  15. Save and build your project.
  16. Publish the form template to a SharePoint Server running Forms Services. Since the form template contains managed code, you will have to perform an administrator-approved form template deployment.

You should now be able disable or enable the drop-down list box control when you click either the Disable or Enable button.
Tip:

You can also toggle between the two states of a control (disabled or enabled) by using the following code in the event handler of one of the Button controls: XPathNavigator domNav = MainDataSource.CreateNavigator();
if (domNav.SelectSingleNode("//my:isControlEnabled", NamespaceManager).Value == "1")
domNav.SelectSingleNode("//my:isControlEnabled", NamespaceManager).SetValue("0");
else
domNav.SelectSingleNode("//my:isControlEnabled", NamespaceManager).SetValue("1");