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

FlashManager and Youtube Videos

6 Answers 122 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Erin
Top achievements
Rank 1
Erin asked on 18 Feb 2009, 09:58 AM
Hello, how can we use the FlashManager to embed a YouTube Video.  I know one of your staff mentioned to use the Flash Manager for You Tube but didn't explain how. 

Thanks!

-Erin

6 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 20 Feb 2009, 06:26 PM
Hello Erin,

The Flash manager of RadEditor does not offer the requested feature to insert YouTube videos out-of-the box. Neverthless, you can very easily create a custom dialog and insert the desired YouTube videos in the editor using the pasteHtml method.

You can see the following live example for more information: Custom Dialog.


Greetings,
Rumen
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Erin
Top achievements
Rank 1
answered on 17 Mar 2009, 07:49 AM
Hi Rumen, I'm running into a problem trying to integrate the solution you gave me. 

The Rad Editor that we use is inside of an update panel and is not visible until an 'edit' button is clicked.  Since the RadEditor is initially not visible, putting the javascript inside of the updatepanel doesn't work.  According to microsoft, this is normal since the panel containing the javascript was initially not visible.  Their suggestion for situations like this is to put the script inside of the code behind's page_load event by using 'Page.ClientScript.RegisterClientScriptBlock' (which we use regularly for other things requiring javascript).  The problem is Page.ClientScript.RegisterClientScriptBlock puts the javascript at the top of the page and not after the radeditor declaration.  This results in a javascript error stating that 'Telerik' is null in the following line:

Telerik.Web.UI.Editor.CommandList[""InsertSpecialLink""] = function(commandName, editor, args).....

My question is, how do I successfully do this in the Page.ClientScript.RegisterClientScriptBlock? 

Or if I can't fully do this in the Page.ClientScript.RegisterClientScriptBlock, how can I set the commandlist argument in the codebehind instead of in javascript.  This would allow me to declare the javascript function by using Page.ClientScript.RegisterClientScriptBlock and set the CommandList["InsertSpecialLink"] in the C# codebehind which would avoid the javascript error.  In otherwords, something like this:

protected void Page_Load(object sender, EventArgs e)
{
     Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "TestPage",
                                                    @"
                                                        function InsertItem(commandName, editor, args)
                                                        {
                                                           var elem = editor.getSelectedElement(); //returns the selected element.
                                                                  
                                                           if (elem.tagName == ""A"")
                                                           {
                                                                editor.selectElement(elem);
                                                                argument = elem;
                                                           }

                                                   ....... the rest of the javascript
                                                    ";

                                        //and something like this (which I know doesn't exist, but I'm looking for an equivalent if you know it)
                                        radEditor.CommandList["InsertSpecialLink"] = "insertItem";
}

Hopefully you can help, I've been banging my head on this one for a while now....


0
Erin
Top achievements
Rank 1
answered on 19 Mar 2009, 05:40 AM
Telerik/Anyone have any suggestions?
0
Tom Gioconda
Top achievements
Rank 1
answered on 19 Mar 2009, 07:19 PM
Page.ClientScript doesn't work because all the telerik controls are dependent on the ajax framework. You have to wait until the init() fires or your code won't find $telerik.  Having to wait until the objects for the ajax framework are created is one of the more irritating things about MS AJAX, but I suppose it is an acceptable tradeoff.

What you're looking for is ScriptManager.RegisterClientScriptBlock() (or RadScriptManger.RegisterClientScriptBlock, they're equivalent).  Any script that interacts with a telerik control (or any ajax stuff) and is inserted via code behind needs to be registered with the scriptmanager or you'll get errors about how things are defined.  The ScriptManager will ensure that your code not only is around on ajax updates, but also that it will be placed correctly and that things are defined in the right order.
0
Erin
Top achievements
Rank 1
answered on 20 Mar 2009, 08:58 AM
Hi Tom, I tried what you suggested and am still getting the 'Telerik is null' error in the javascript.  Any other suggestions? 

The problem is that ScriptManager.RegisterClientScriptBlock also seems to put the javascript before the RadEditor declaration.

Telerik, is there no other way to do this?  Is it possible to directly add this feature in the source code somehow so that one doesn't have to deal with all this javascript to add a button?  All this could be avoided if there is a way to do this in the codebehind or by adding it to the source code directly (is this possible?).  I would really appreciate some kind of response to this matter.
0
Rumen
Telerik team
answered on 23 Mar 2009, 09:31 AM
Hi Erin,

Could you please wrap the JavaScript command of the custom button in if (typeof(RadEditorCommandList) != "undefined") clause and firing it in the pageLoad function of ASP.NET AJAX framework, e.g.

    <script type="text/javascript" language="javascript">
       function pageLoad()
        {
            if (typeof(RadEditorCommandList) != "undefined")
            {
                Telerik.Web.UI.Editor.CommandList["InsertSpecialLink"] = function(commandName, editor, oTool)
                {
                    alert("InsertSpecialLink command called");
                };
            }
        }
    </script>


Kind regards,
Rumen
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Tags
Editor
Asked by
Erin
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Erin
Top achievements
Rank 1
Tom Gioconda
Top achievements
Rank 1
Share this question
or