Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

Handler was not added through the Sys.UI.DomEvent.addHandler method. (a solution)

$
0
0

The following is a solution to the above error I encountered. Hopefully I can save others with a similar problem from endless hours of sifting through unhelpful answers.

I searched and searched and only found suggestions that recommended I do the following.

  1. Change the ToolkitScriptManager ScriptMode from "Debug" to "Release"

  2. In web.config change <compilation debug="true" targetFramework="4.0"> to <compilation debug="false" targetFramework="4.0">

Neither suggestion worked for me, either separately or combined.

Problem

I had a GridView (simplified)

<asp:Panel ID="Panel_GridView_Data" runat="server"><asp:UpdatePanel ID="UpdatePanel_GridView_Data" runat="server" UpdateMode="Conditional"><ContentTemplate><asp:GridView ID="GridView_Data"><Columns><asp:TemplateField><uc:GridView_Details runat="server" ID="UserControl_GridViewDetails" /></asp:TemplateField></Columns></asp:GridView></ContentTemplate></asp:UpdatePanel></asp:Panel>

In the UserControl (simplified)

<asp:LinkButton ID="LinkButton_GridView_DataDetailId" runat="server" Text='<%# Eval("SomeId") %>' /><asp:ModalPopupExtender ID="ModalPopupExtender_GridView_DataDetails" runat="server" 
	TargetControlID="LinkButton_GridView_DataDetailId" 
	PopupControlID="Panel_DataDetails"
	CancelControlID="ModalPopupExtender_GridView_DataDetails_Close"></asp:ModalPopupExtender><asp:Panel ID="Panel_DataDetails" runat="server" style="display:none" ><asp:UpdatePanel ID="UpdatePanel_Details" runat="server" UpdateMode="Conditional"><ContentTemplate><asp:FormView ID="FormView_BroachDetails" runat="server"><ItemTemplate></ItemTemplate></asp:FormView><asp:Button ID="ModalPopupExtender_GridView_DataDetails_Close" runat="server" Text="Close"
				OnClick="ModalPopupExtender_GridView_DataDetails_Close_Close_Click"/></ContentTemplate></asp:UpdatePanel>		</asp:Panel>

Solution

Originally I didn't have the ModalPopupExtender_GridView_DataDetails_Close control because I was using the CancelControlID of the ModalPopupExtender to close the Panel.

Problem arose when I entered into Edit mode in the FormView. Upon save or cancel the 'Close' button for the Modal would not work, no error, just wouldn't close. I looked back at the page I copied the structure from and saw that I had added a OnClick event to the Button control and thus closed the Panel from code, so I did the same here.

When I added the OnClick event I didn't remove the CancelControlID property from the ModalPopupExtender. This oversight was causing the 'Sys.UI.DomEvent.addHandler' error.

Finally after hours of fruitless searching I returned to the html and reviewed the page attempting to find differences in the two pages. Somehow I noticed the aforementioned CancelControlID (I would have expected myself to overlooked that).

I promptly removed it and the error stopped.


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>