I saw similar problems and answers, but no one seems to fix the problem.
I have a user control inside the update panel. Inside my user control, I output javascript.
javascript doesn't work when fired. If I move javascript to the parent page outside the usercontrol / update panel, it starts. This does not make sense, since I cannot use this usercontrol on another page without duplicating the code ... by duplicating all javascript (another site) or adding links to the .js file on every page that he used on (the same site) . It is less portable
I just want to output javascript using a control (inside the update panel).
The updated panel is mentioned for the accuracy of what I am doing. It does not work even if I place usercontrol outside of service packs.
Keeping simplicity (this does not work for me):
UserControl:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="_location.ascx.cs" Inherits="_location" %> <script type="text/javascript"> function test() { alert('Hello World!'); } </script> <a href="javascript:void(0);" onclick="javascript:test();"> Find For Me </a>
PARENTS:
<uc1:_location runat="server" ID="_location" />
Debugging in chrome tells me: "Untrained ReferenceError: test not defined"
If I add javascript directly to onclick, as shown below, it works:
onclick="alert('Hello World!');"
And as stated above, moving the function to the parent page ALSO works.
It is as if the browser is ignoring the output of the script from the user control.
Any ideas?