locked
ErrorSummary doesn't exist until form is visible RRS feed

  • Question

  • I have a scenario where I needed a tab control to display an edit form (two tabs, one set of save buttons).  So I placed one DataForm on one tab, and a second on another tab.  If I don't access the second tab (i.e. - dataForm2 is never made visible) and simply save changes made on the first tab,  the ErrorSummary on the second tab , "dataForm2.ErrorSummary", is null even though I have called the dataForm2.ValidateItem(). 

                dataForm1.ValidateItem();
                dataForm2.ValidateItem();
                if ((!dataForm1.ErrorSummary.HasErrors)
                    && (!dataForm2.ErrorSummary.HasErrors))
                { ... }

    Is this correct?  Am I missing something? 

    Also, whether or not I have a required field on dataForm2, it makes no difference. 

     
    Wednesday, June 17, 2009 8:25 AM

Answers

  • Items on secondary tabs are not loaded until the first time you view the tab.  The ErrorSummary in the DataForm is in the template, which doesn't get loaded until the control gets loaded.  You will likewise face similar problems with any other control which perform actions on template parts.   Some of your options include calling ValidateItem only after that control is loaded, putting summary controls outside of the TabControl, or use an alternative to TabControl where you toggle the opacity.

    Wednesday, June 17, 2009 8:22 PM