I am using the code posted on this forum for adding a custom print button to the RadWindow title bar. The code seems to work, but I get an error on the page that seems to be related to issuing the "insertBefore" command. The code is provided in this post below.
The error message is:
Message: Sys.ArgumentUndefinedException: Value cannot be undefined.
Parameter name: handler
Line: 2472
Char: 16
Code: 0
<telerik:RadScriptBlock runat="server" ID="RadScriptBlock1">
<script type="text/javascript">
var radWnd;
function <%=ClientID%>_OpenPrintWindow(url){
radWnd = radopen(url, null);
radWnd.set_title('Print Contract Form');
radWnd.set_modal(true);
radWnd.setSize(750,500);
radWnd.center();
radWnd.set_visibleStatusbar(false);
radWnd.add_show(OnClientShow());
radWnd.set_behaviors(Telerik.Web.UI.WindowBehaviors.Move +
Telerik.Web.UI.WindowBehaviors.Close +
Telerik.Web.UI.WindowBehaviors.Resize);
}
function OnClientShow()
{
var TitleBar = radWnd.GetTitlebar();
var parent = TitleBar.parentNode;
var oUL = parent.getElementsByTagName('UL')[0];
if (!(oUL.firstChild.id == "customprintbuttonID")) // Check if the element is already added
{
// If not - create and add the custom button
oUL.style.width = "192px";
var oLI = document.createElement("LI");
oLI.id = "customprintbuttonID"
var aPrintBtn = document.createElement("A");
oLI.appendChild(aPrintBtn);
aPrintBtn.className = "customprintbutton";
aPrintBtn.href = "javascript:void(0)";
aPrintBtn.title = "Print Content";
aPrintBtn.onmousedown = printWin;
oUL.insertBefore(oLI, oUL.firstChild);
}
}
function printWin(e)
{
var content = radWnd.GetContentFrame().contentWindow;
var printDocument = content.document;
if (document.all)
{
printDocument.execCommand("Print");
}
else
{
content.print();
}
//Cancel event!
if (!e) e = window.event;
return $telerik.cancelRawEvent(e);
}
</script>
</telerik:RadScriptBlock>
The error message is:
Message: Sys.ArgumentUndefinedException: Value cannot be undefined.
Parameter name: handler
Line: 2472
Char: 16
Code: 0
<telerik:RadScriptBlock runat="server" ID="RadScriptBlock1">
<script type="text/javascript">
var radWnd;
function <%=ClientID%>_OpenPrintWindow(url){
radWnd = radopen(url, null);
radWnd.set_title('Print Contract Form');
radWnd.set_modal(true);
radWnd.setSize(750,500);
radWnd.center();
radWnd.set_visibleStatusbar(false);
radWnd.add_show(OnClientShow());
radWnd.set_behaviors(Telerik.Web.UI.WindowBehaviors.Move +
Telerik.Web.UI.WindowBehaviors.Close +
Telerik.Web.UI.WindowBehaviors.Resize);
}
function OnClientShow()
{
var TitleBar = radWnd.GetTitlebar();
var parent = TitleBar.parentNode;
var oUL = parent.getElementsByTagName('UL')[0];
if (!(oUL.firstChild.id == "customprintbuttonID")) // Check if the element is already added
{
// If not - create and add the custom button
oUL.style.width = "192px";
var oLI = document.createElement("LI");
oLI.id = "customprintbuttonID"
var aPrintBtn = document.createElement("A");
oLI.appendChild(aPrintBtn);
aPrintBtn.className = "customprintbutton";
aPrintBtn.href = "javascript:void(0)";
aPrintBtn.title = "Print Content";
aPrintBtn.onmousedown = printWin;
oUL.insertBefore(oLI, oUL.firstChild);
}
}
function printWin(e)
{
var content = radWnd.GetContentFrame().contentWindow;
var printDocument = content.document;
if (document.all)
{
printDocument.execCommand("Print");
}
else
{
content.print();
}
//Cancel event!
if (!e) e = window.event;
return $telerik.cancelRawEvent(e);
}
</script>
</telerik:RadScriptBlock>