I'm trying to get a javascript block to work within a RadDock:
<telerik:RadDock ID="RadDock5" runat="server" Width="300px">
<ContentTemplate>
<%= DateTime.Now %>
<br />
<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
<script type='text/javascript' src='http://www.worldtimeserver.com/clocks/embed.js'></script>
<script type="text/javascript">
objGB = new Object; objGB.wtsclock = 'wtsclock001.swf';
objGB.color =
'FFCC33'; objGB.wtsid = 'JP';
objGB.width = 100; objGB.height = 100;
objGB.wmode =
'transparent'; showClock(objGB);
alert(
"after");
</script>
</telerik:RadScriptBlock>
</ContentTemplate>
</telerik:RadDock>
It always works on a full page refresh. On a partial page refresh, time is updated and the alert shows, but the javascript object disappears.
What's up? I've been banging my head for weeks with this and other possible solutions.
(the RadDock is part of a standard RadDockLayout set up, by the way)
thanks
4 Answers, 1 is accepted
Could you please try to create an example with this control in an UpdatePanel (without RadDock and RadCodeBlock) after that I'll implement it with RadCodeBlock and RadDock.
It seems to have to do with Javascript and object persistance. I've even tried injecting javascript into the page HTML by subclassing the Render method.
If anyone can help or has ideas, that would be great.
thanks!
I wrapped the "clock control" content in a DIV and everything is fine after ajax.
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %> |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
<html xmlns="http://www.w3.org/1999/xhtml"> |
<head> |
<title></title> |
<script type="text/javascript"> |
function showClock(obj) { |
var str = 'bed src="http://www.worldtimeserver.com/clocks/' + obj.wtsclock + "?"; |
for (prop in obj) { |
if ('wtsclock' == prop |
|| 'width' == prop |
|| 'height' == prop |
|| 'wmode' == prop |
|| 'type' == prop |
) continue; |
str += (prop + "=" + _escape(obj[prop]) + "&"); |
} |
str += '" '; |
str += ' width="' + obj.width + '"'; |
str += ' height="' + obj.height + '"'; |
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false; |
if (isOpera != true) { |
str += ' wmode="' + obj.wmode + '"'; |
} |
str += ' type="application/x-shockwave-flash" allowscriptaccess="always" \/\>'; |
//document.write("\<em" + str); |
///CHANGED CODE |
$get("myDiv").innerHTML = "\<em" + str; |
} |
function _escape(str) { |
strstr = str.replace(/ /g, '+'); |
strstr = str.replace(/%/g, '%25'); |
strstr = str.replace(/\?/, '%3F'); |
strstr = str.replace(/&/, '%26'); |
return str; |
} |
</script> |
</head> |
<body> |
<form id="form1" runat="server"> |
<asp:ScriptManager ID="ScriptManager1" runat="server"> |
</asp:ScriptManager> |
<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server"> |
<asp:Button ID="Button1" runat="server" Text="btnCallback" /> |
<div id="myDiv"> |
<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server"> |
<script type="text/javascript"> |
objGB = new Object; |
objGB.wtsclock = 'wtsclock001.swf'; |
objGB.color = 'FFCC33'; |
objGB.wtsid = 'JP'; |
objGB.width = 100; |
objGB.height = 100; |
objGB.wmode = 'transparent'; |
showClock(objGB); |
</script> |
</telerik:RadScriptBlock> |
</div> |
</telerik:RadAjaxPanel> |
</form> |
</body> |
</html> |
THAT'S IT!!!!!!
WOW, WOW, WOW!!!
At first, I didn't take out the original reference to embed.js, so it didn't work, but now I've got it within a RadDock doing async postbacks.
Thank you so much.