HTMLPlaceHolder & IFrame Problem

HTMLPlaceHolder & IFrame Problem

Post by Tsachi Mal » Fri, 25 Jul 2003 19:42:02


ilipe,

I have a simple and elegent solution to allow the
HtmlPlaceholder to accept Flash and any other type of
object or tags (like Iframe) that you want to insert.

the idea is to simply wrap the object with unique user-
defined html comments and then uncomment the comment tag
when displaying.

Outside the tag you can write any text that you want.
This way you can combine regular HTML,objects or anything
you want.

Note that you are not limited to the number of objects to
display.


Here is The sample flash tag you insert to the
HTMLPlaceholder.
=====================================
<!--startobject

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-
444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs
/flash/swflash.cab#version=6,0,29,0" width="50"
height="50">
<param name="movie" value="http://flash.swf">
<param name="quality" value="high">
<embed src="http://flash.swf" quality="high"
pluginspage="http://www.macromedia.com/go/getflashplayer"
type="application/x-shockwave-flash" width="50"
height="50"></embed></object>

endobject-->
==============================================

This is the code that removes the comment tags to display
the Flash object.

========================================================
CmsHttpContext CMSContext = CmsHttpContext.Current;
// Get Placeholder
HtmlPlaceholder plhText =
(HtmlPlaceholder) CMSContext.Posting.Placeholders
["ContentPlaceHolder"];
int
StartObject,EndObject,StartObjectTag,EndObjectTag;
string FixedText,ObjectTag;
if (CmsHttpContext.Current.Mode ==
PublishingMode.Unpublished &&
CmsHttpContext.Current.UserCanAuthor == true)
{ // We are in "Edit" mode
HtmlContent = "";

ContentPlaceHolder.Visible=true;

}
else
{ // We are in "Live" mode
HtmlContent =
plhText.Html.ToString();
ObjectTag=plhText.Text;

StartObject=HtmlContent.IndexOf("<!--
startobject");

EndObject=HtmlContent.IndexOf("endobject-->");
FixedText="";
while (StartObject>-1 &&
EndObject>-1)
{

StartObjectTag=ObjectTag.IndexOf("<!--
startobject");

EndObjectTag=ObjectTag.IndexOf("endobject-->");
if (StartObject>-1
&& EndObject>-1)
{

FixedText=FixedText+HtmlContent.Substring
(0,StartObject)+ObjectTag.Substring
(StartObjectTag+15,EndObjectTag-(StartObjectTag+15));

if
(EndObject+15<HtmlContent.Length-1)
{

HtmlContent=HtmlContent.Remove(0,EndObject+15);
}
else
{

HtmlContent="";
}



if
(EndObjectTag+13<ObjectTag.Length-1)
{

ObjectTag=ObjectTag.Remove(0,EndObjectTag+13);
}
else
{

ObjectTag="";
}
}

StartObject=HtmlContent.IndexOf("<!--
startobject");

EndObject=HtmlContent.IndexOf("endobject-->");
}

HtmlContent=FixedText+HtmlContent;

ContentPlaceHolder.Visible=false;

}
=======================================

Hope this will help.