<asp:Button ID="btnUpdate" runat="server" Text="Update" />
<asp:UpdatePanel ID="upCoupons" runat="server" UpdateMode="Conditional"> <ContentTemplate>
</ContentTemplate>
</asp:UpdatePanel>
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"
upCoupons.Triggers.Add(upTrigger)
To my page load event Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles 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 Object, ByVal e As System.EventArgs) Handles Me.Load
Dim upTrigger As New AsyncPostBackTrigger()
upTrigger.ControlID = btnUpdateCartQty.UniqueID
upTrigger.EventName = "Click"
upCoupons.Triggers.Add(upTrigger)
Hope this helps you and saves you time.