Monday, March 26, 2012

UpdatePanel + Javascript + UserControl

Hi all

I have a Usercontrol which has a scriptblock with a javascript method in it. This is fired by a control within the usercontrol

...

<input type=submit onclick="MyFunction()"/>

...

<script...>

function MyFunction()
{
alert("Hello World");
}
</script>

This works fine on the page until i surround the usercontrol in an UpdatePanel. When i do this i get a js error, cannot find the method MyFunction();

I have tried to use clientscript.Register...Script(); methods, have had the javascript in its own javascript file, have used the defer tag and still it does not work. Currently I have the control in the UpdatePanel and the script tag which points to a js file on the page itself.

I have seen posts like this before, but no-one seems to have solved it. Is this a known issue? Or has someone solved it and I just cant find it on the boards? Or am I simply not doing something?


Thanks in advance

S.

Hi Penny, exact same problem solved here -->http://forums.asp.net/thread/1503014.aspx

:)

Jim


Thanks Jim -

I'll try it over Christmas.


S.

No comments:

Post a Comment