This is a migrated thread and some comments may be shown as answers.

RadScriptBlock inside RadDock not working

4 Answers 164 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Rich Erwin
Top achievements
Rank 1
Rich Erwin asked on 21 Sep 2009, 01:44 AM

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

Sort by
0
Obi-Wan Kenobi
Top achievements
Rank 1
answered on 22 Sep 2009, 01:26 PM
I don't think that this problem is related to RadDock or RadCodeBlock. I tried the code without RadDock and RadCodeBlock, just the "clock control"  in an UpdatePanel and it doesn't work.
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.
0
Rich Erwin
Top achievements
Rank 1
answered on 22 Sep 2009, 02:08 PM
I've tried that, too.

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!
0
Accepted
Obi-Wan Kenobi
Top achievements
Rank 1
answered on 22 Sep 2009, 03:26 PM
The problem is that the showClock(http://www.worldtimeserver.com/clocks/embed.js ) method uses document.write.
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(/&amp;/, '%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> 
 
 Hope this helps!
0
Rich Erwin
Top achievements
Rank 1
answered on 23 Sep 2009, 12:09 AM

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.
Tags
Ajax
Asked by
Rich Erwin
Top achievements
Rank 1
Answers by
Obi-Wan Kenobi
Top achievements
Rank 1
Rich Erwin
Top achievements
Rank 1
Share this question
or