I am working on a custom Skin Object to perform various client side tasks. I have my Javascript in it's own JS file which needs to initialized in the body onload event. According to the DotNetNuke Client API documentation, the correct way to accomplish this is to use DotNetNuke.UI.Utilities.ClientAPI.RegisterStartUpScript to include my script and DotNetNuke.UI.Utilities.DNNClientAPI.AddBodyOnloadEventHandler to call my initialization function. It all seems straight forward, however, when deployed the fruits of my efforts, nothing happened. I verified that the Page Source included the client script but the onload function never fires. I have since backed my code down to just the following code running in the Page_Load event:
Dim strScript As String = "<script type='text/javascript' src='/Resources/Scripts/prc.js'></script>" & _
"<script type='text/javascript'>" & vbNewLine & _
"//<![CDATA[" & vbNewLine & _
"function __prc_Initialize() { try { prc.Initialize(); } catch (ex) { nable to initialize \'prc\' client API.'); } }" & vbNewLine & _
"//]]>" & vbNewLine & _
"</script>" & vbNewLine
'DotNetNuke.UI.Utilities.ClientAPI.RegisterStartUpScript(Me.Page, "prc.Initialize", strScript)
DotNetNuke.UI.Utilities.DNNClientAPI.AddBodyOnloadEventHandler(Me.Page, " dnn_onload');") ' "__prc_Initialize();")
Yet the JS alert still never fires. Here is an exerpt from the page source which is exactly what I expected:
<input name="__dnnVariable" type="hidden" id="__dnnVariable" value="__dnn_pageload dnn_onload');<snip/>" />
As you can see it is there ready for to be evaluated but does not fire. We are still using DNN 4.6.2 with many custom modules, many using AjaxPro and AjaxControlToolkit without issue.
I must be missing something. Please advise.
Thanks in advance for your help.