Smit Shah

a control with id could not be found for the trigger in updatepanel

<asp:Button ID="btnUpdate" runat="server" Text="Update" />

<asp:UpdatePanel ID="upCoupons" runat="server" UpdateMode="Conditional"> <ContentTemplate>

Server Error in '/' Application.

A control with ID 'btnUpdate' could not be found for the trigger in UpdatePanel 'up'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.InvalidOperationException: A control with ID 'btnUpdate' could not be found for the trigger in UpdatePanel 'up'.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 

[InvalidOperationException: A control with ID 'btnUpdate' could not be found for the trigger in UpdatePanel 'up'.]
   System.Web.UI.UpdatePanelControlTrigger.FindTargetControl(Boolean searchNamingContainers) +460191
   System.Web.UI.AsyncPostBackTrigger.Initialize() +27
   System.Web.UI.UpdatePanelTriggerCollection.Initialize() +79
   System.Web.UI.UpdatePanel.Initialize() +40
   System.Web.UI.UpdatePanel.OnLoad(EventArgs e) +51
   System.Web.UI.Control.LoadRecursive() +74
   System.Web.UI.Control.LoadRecursive() +146
   System.Web.UI.Control.LoadRecursive() +146
   System.Web.UI.Control.LoadRecursive() +146
   System.Web.UI.Control.LoadRecursive() +146
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272              
After some research, here is what I found
I had to add
Dim upTrigger As New AsyncPostBackTrigger()
upTrigger.ControlID = btnUpdateCartQty.UniqueID
upTrigger.EventName = "Click"
To my page load event Protected Sub Page_Load(ByVal sender As ObjectByVal e As System.EventArgsHandles Me.Load 
But after the first postback it did a full postback again.
That is when I realized it had to be bound on every postback.
So the code looks like this
Protected Sub Page_Load(ByVal sender As ObjectByVal e As System.EventArgsHandles Me.Load

Dim upTrigger As New AsyncPostBackTrigger() 
upTrigger.ControlID = btnUpdateCartQty.UniqueID 
upTrigger.EventName = "Click" 
End Sub
Hope this helps you and saves you time.

This is a personal weblog. The opinions expressed here represent my own and not those of my employer. For accuracy and official reference refer to MSDN/ TechNet/ BOL /Other sites that are authorities in their field. Me or employer do not endorse any tools, applications, books, or concepts mentioned on the site. I have documented my personal experience on this site. The information on this site may not be up to date or accurate at times, if you are not sure or have a question, please contact me to verify information.