Microsoft Content Management Server - SingleImagePlaceholder renders to <span><a ..><img /></a> <

This is Interesting: Free IT Magazines  
Home > Archive > Microsoft Content Management Server > November 2005 > SingleImagePlaceholder renders to <span><a ..><img /></a> <





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author SingleImagePlaceholder renders to <span><a ..><img /></a> <
Joe C

2005-11-15, 5:57 pm

It seems that the SingleImagePlaceholder always renders to three tags in the
following structure:
<span><a ..><img /></a> </span>
Is there a way that I can force it to not render the <a> tag? Even when I
set the 'allow hyperlinks' property on the placeholder, I still get this <a>
tag.

Thanks
Joe
Stefan [MSFT]

2005-11-16, 7:52 am

Hi Joe,

to achieve this you would need to create a custom placeholder control that
derives from the original SingleImagePlaceholderControl.
In your custom placeholder control you need to override the Render method,
consume the generated html and remove the unwanted tags.
Then return the modified html as a result of the Render method.

This would look like the following:

protected override void Render(System.Web.UI.HtmlTextWriter output)
{
if ((WebAuthorContext.Current.Mode !=
WebAuthorContextMode.AuthoringReedit)
&&(WebAuthorContext.Current.Mode != WebAuthorContextMode.AuthoringNew))
{
// catch the output of the original HtmlPlaceholderControl
TextWriter tempWriter = new StringWriter();
base.Render(new System.Web.UI.HtmlTextWriter(tempWriter));

string orightml= tempWriter.ToString();

// remove the unwanted tags
string newhtml = orightml.Replace(...);

output.Write(newhtml);
}
else
{
base.Render(output);
}
}

Cheers,
Stefan

--
This posting is provided "AS IS" with no warranties, and confers no rights

New to MCMS?
Check out this book: Building Websites Using MCMS: http://tinyurl.com/6zj44
Check out the new book as well: Advanced MCMS development:
http://tinyurl.com/8ugwj
----------------------


"Joe C" <JoeC@discussions.microsoft.com> wrote in message
news:CFC0507D-6D44-4970-83F4-93C9EBC3A027@microsoft.com...
> It seems that the SingleImagePlaceholder always renders to three tags in
> the
> following structure:
> <span><a ..><img /></a> </span>
> Is there a way that I can force it to not render the <a> tag? Even when I
> set the 'allow hyperlinks' property on the placeholder, I still get this
> <a>
> tag.
>
> Thanks
> Joe



Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com