Issue with getting control id when tabcontainer is used
-
28-05-2021 - |
Question
I have an AJAX Control Toolkit TabContainer
in my ASP.NET page. In one of the tabs in the TabContainer
, there is a GridView
. Now, I have an UpdatePanel
for which I want to give trigger as "RowCommand" of GridView
mentioned above. The UpdatePanel
is outside the TabContainer
. But when I give the GridView
id, I am getting the error:
A control with ID 'grvSummary' could not be found for the trigger in UpdatePanel 'updSegment'.
Trigger markup:
<asp:AsyncPostBackTrigger ControlID="grvSummary" EventName="RowCommand" />
Solution
You will have to programmatically add the trigger to your UpdatePanel
. This is because your GridView may or may not start in a different ContentPlaceHolder
than the UpdatePanel
(namely, the <ContentTemplate>
of your TabContainer
). Like this (note that this really needs to be done in Page_Init
, due to the Page Life Cycle):
protected void Page_Init(object sender, EventArgs e)
{
AsyncPostBackTrigger trig = new AsyncPostBackTrigger();
trig.ControlID = grvSummary.UniqueID;
trig.EventName = "RowCommand";
updSegment.Triggers.Add(trig);
}
It looks like this may be a problem with ASP.NET / AJAX assuming the wrong Control.UniqueID
value for the Control
being used as a trigger.
Source: Triggering an UpdatePanel in a different ContentPlaceHolder