Sunday, September 21, 2008

the easiest way to communicate between controls on different tabs in the Infragistics WebTab

When creating a WebTab, you may be tempted to take the easy route of filling up the tabs by setting the TargetURL property of each tab to a page you've already created.

There is nothing wrong with this method...unless you require communication between those tabs, in which case setting the TargetURL will essentially hide the contents of those tabs from the parent page. This happens because setting the TargetURL places that target page in an IFRAME on the parent page, and since the structure within frames is invisible to the containing page in ASP.NET, it is then very difficult to access child controls).

Your next option would be to place the controls directly on the tabs using the template editor. While this improves your abilities to access controls, attaching events to those controls becomes a bit cumbersome, requiring you to rewire the event handlers on each Page Load event.

Your third option is to place all your controls within a Web User Control, and then place the user control into the tab via the template editor. By doing this, you'll maintain your ability to handle events (via the user controls' code behind page) and your ability to access child controls (either by making objects themselves public or by creating methods and accessors to modify properties). The attached samples illustrate how to communicate between user controls on different tabs and how to access child controls from the main page.

No comments: