This project is read-only.

Raw HTML For A Page, Not A Post

Topics: Business Logic Layer
May 1, 2011 at 5:19 PM

I'm trying to use an iFrame tag inside of a 'Page' with BlogEngine.Net; but I can't seem to do it.  If I click the 'HTML' button, a window pops up and when I add my iFrame tag and hit Okay, it disappears.  

I've noticed that, when I'm editing a 'Post' there is a checkbox that says 'Raw HTML' or something similar.  If I click that, I can enter my iFrame and it works great; for that *post*.  But I want this to be in a *page*.

How do I directly modify the HTML of a page?  I tried editing the XML data directly; but that didn't seem to work at all.  Is this missing checkbox a bug?

May 1, 2011 at 8:46 PM
Edited May 1, 2011 at 8:50 PM

There is a recent answer to this in the forum, but I can't find it right now.

The tinyMCE editor is probably the cause.

Open the tinyMCE.ascx file in the BE admin folder.

Look for the line beginning


At the end of this line insert the following before the closing quotation mark


It should look something like this once edited

extended_valid_elements: "object[width|height|classid|codebase],param[name|value],embed[src|type|width|height|flashvars|wmode],iframe[src|width|height|name|align|frameborder]",

Just be careful to retain the format, entries within the double quotes are separated by a comma except for the last entry.


The raw HTML editor would be useful in pages, I'm not sure why it's not included

May 1, 2011 at 10:28 PM

I found the tinyMCE.ascx file; but I don't see anything that says 'extended_valid_elements' - am i looking in the wrong place?

May 1, 2011 at 11:07 PM

I found an example online, now my .ascx file looks like

theme_advanced_resizing: true,       
theme_advanced_resize_horizontal : false,
extended_valid_elements: "iframe [name|id|src|frameborder|width|height|allowtransparency]",
tab_focus : ":prev,:next",

But I still can't get it to accept an iFrame

May 1, 2011 at 11:11 PM

That's surprising, there is normally something for that entry, if you are definitely in that file then add the line.

You should be looking at something like this (contents of mine)

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="tinyMCE.ascx.cs" Inherits="Admin.TinyMce" %>
<%@ Import Namespace="BlogEngine.Core" %>

<script type="text/javascript" src="<%=Utils.RelativeWebRoot %>editors/tiny_mce_3_3_9_2/tiny_mce.js"></script>
<script type="text/javascript">

        // General options
        mode: "exact",
        elements: "<%=txtContent.ClientID %>",        
        extended_valid_elements: "object[width|height|classid|codebase],param[name|value],embed[src|type|width|height|flashvars|wmode],iframe[src|width|height|name|align|frameborder]",
        theme: "advanced",
        plugins: "inlinepopups,paste,searchreplace,fullscreen,contextmenu,emotions,table,advlink,xhtmlxtras,footnotes,wikipedia,spellchecker,ytEmbed,ytViewer",
        convert_urls: false,

        // Theme options
        theme_advanced_buttons1: "fullscreen,code,|,cut,copy,paste,pastetext,pasteword,|,search,replace,|,undo,redo,|,bold,italic,underline,strikethrough,|,sub,sup,|,acronym,wikipedia,|,blockquote,cite,|,footnotes,|,justifyleft,justifycenter,justifyright,|,bullist,numlist,outdent,indent",
        theme_advanced_buttons2: "link,unlink,removeformat,cleanup,charmap,emotions,|,formatselect,fontselect,fontsizeselect,|,forecolor,backcolor,|,attribs,|,spellchecker,|,ytEmbed,ytViewer",
        theme_advanced_buttons3: "",
        theme_advanced_toolbar_location: "top",
        theme_advanced_toolbar_align: "left",
        theme_advanced_statusbar_location: "bottom",
        theme_advanced_resizing: true,
        theme_advanced_resize_horizontal: false,
        tab_focus: ":prev,:next",        
        spellchecker_rpc_url: "/TinyMCEHandler.aspx?module=SpellChecker",

        //Character count        
        theme_advanced_path: false,

        setup: function (ed) {
            ed.onKeyUp.add(function (ed, e) {
                var strip = (tinyMCE.activeEditor.getContent()).replace(/(<([^>]+)>)/ig, "");
                var text = strip.split(' ').length + " Words, " + strip.length + " Characters";
                tinymce.DOM.setHTML(tinymce.DOM.get( + '_path_row'), text);
            //Add blur event when the editor is initialised
            ed.onInit.add(function (ed) {
                if (!tinymce.isIE) {
                    tinyMCE.dom.Event.add(ed.getWin(), "blur", function () {

<asp:TextBox runat="Server" ID="txtContent" CssClass="post" Width="100%" Height="250px" TextMode="MultiLine" />

May 1, 2011 at 11:15 PM

You may have to play around with the iframe parameters, getting that exactly right is important, try it using the code from my file.

This works for me.

May 1, 2011 at 11:18 PM

I have to log off now, let me know how you get on, it may be trial and error but you should get it working.

May 1, 2011 at 11:19 PM

Thanks so much; that did the trick.

May 1, 2011 at 11:22 PM

Good man, I can now drink the rest of my beer with that happy good deed for the day feeling, glad it helped.

May 2, 2011 at 4:12 PM
Edited May 2, 2011 at 4:12 PM

Message deleted. Wrong thread.