Wednesday, March 28, 2012

pageLoad javascript function not being called

for some reason the javascript pageLoad method is not being called

the javascript is in scirbble.js

the example i have followed informs me that the pageLoad method should be ran when the atlas script manager control has loaded.

Is this corret.

Could someone please point me in the right direction for getting the below code to work

Below is the javascript and aspx code

function pageLoad()
{
var surface = document.getElementById("drawingSurface");
image = surface.getElementsByTagName("IMG")[0];
originalSrc = image.src;

surface.attachEvent("onmousedown", startStroke);
surface.attachEvent("onmouseup", endStroke);
surface.attachEvent("onmouseout", endStroke);
surface.attachEvent("onmousemove", addPoints);
}

form id="form1" runat="server">
<Atlas:ScriptManager ID="AtlasScriptManager" runat="server" >
<Services>
<Atlas:ServiceReference Path="ScribbleService.asmx" />
</Services>
<Scripts>
<Atlas:ScriptReference Path="ScriptLibrary\Scribble.js" />
</Scripts>
</Atlas:ScriptManager>
<div id="drawingSurface"
style="border:solid 1px black;height:200px;width:200px">
<img alt="Scribble" src="http://pics.10026.com/?src=ScribbleImage.ashx"
style="height:200px;width:200px" />
</div>
</form>

i have the same problem since the last release. I had pageLoad() methods which were able to set elements on the initial loading which no longer fire automatically :?(

As a workaround, you can attach to thePageRequestManager events like so :

<script type="text/javascript"> Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(pageLoad);</script>

when i do the above mentioned work around i get an error

'Sys.WebForms.PageRequestManager' is null or not an object

i have tried adding the script above and below the sript manager html elements but it makes no diffrence.

below is the aspx page

any help would glady be appreciated.

<headrunat="server">

<title>Atlas Scribble Sample</title>

</

head><body><formid="form1"runat="server"><Atlas:ScriptManagerID="AtlasScriptManager"runat="server"EnablePartialRendering=true><Services><Atlas:ServiceReferencePath="ScribbleService.asmx"/></Services><Scripts><Atlas:ScriptReferencePath="ScriptLibrary\Scribble.js"/></Scripts></Atlas:ScriptManager><divid="drawingSurface"style="border:solid 1px black;height:200px;width:200px"><imgalt="Scribble"src="ScribbleImage.ashx"style="height:200px;width:200px"/></div><scripttype="text/javascript">

Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(pageLoad);

</script></form>

</

body>

</

html>
throw an alert into your pageLoad() function to see if it's getting called; my guess is that it is, at least nothing you've posted here would prevent it. The issue I see is that the element 'surface' isn't going to respond to the attachEvent function as you have it written, at least not in this framework. You could try to us $addHandler(surface,'onmousedown',startStroke); instead.

No comments:

Post a Comment