• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 727
  • Last Modified:

Can a control trigger itself for AJAX.NET?

I have a TreeView control in AJAX.NET 2.0 / C#. What I'm trying to do is set a trigger on an UpdatePanel that comes from itself. Is this possible? Here's what I'm trying to do but gives a compile error saying it can't find the event name:

        <asp:UpdatePanel ID="TreeUpdatePanel1" runat="server" UpdateMode="Conditional">
        <asp:TreeView ID="TreeView1" runat="server"
                OnSelectedNodeChanged="TreeView1_SelectedNodeChanged" >
            <asp:AsyncPostBackTrigger ControlID="TreeView1" EventName="ExpandNode" />

The error I get is this:
Could not find an event named 'ExpandNode' on associated control 'TreeView1' for the trigger in UpdatePanel 'TreeUpdatePanel1'.

Can I trigger a control with an event from itself?
1 Solution
Tommie Nathaniel Carter, Jr., MBACommented:
If the control has sub controls. The subs have events bound to them then I expect this would work.
For the update panel, set ChildrenAsTriggers = True.  With that then every control in the update panel will cause the asynch postback without explicity setting it in the Triggers node.  The control's event will need to cause a postback of course for this to work.  If ExpandNode doesn't cause a postback normally then it won't cause the UpdatePanel to fire either.

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now