Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to modify url tag output format in a placeholder

0 views
Skip to first unread message

andrew007

unread,
Aug 8, 2005, 9:53:01 PM8/8/05
to
I used the following override to change how url text looks like but not sure
how to change url tag.

protected override void Render (System.Web.UI.HtmlTextWriter output)

what I want to do is I want to change output stream html by htmlplaceholder
as follows

from
<a href="test.htm">test</a>
to
<a href="test.htm" target="_new">test</a>

basically I want to have any link tag to be opened in a new windows when
users click this url placeholder.
Please help me if you know any ideas to override a certain methods to make
this happen.

Stefan [MSFT]

unread,
Aug 9, 2005, 12:54:01 AM8/9/05
to
Hi Andrew,

I assume this should only happen during presentation mode, right? Not in
authoring mode?
Then you should override the LoadPlaceholderContentForAuthoring method of
the HtmlPlaceholderControl.

Do the following:

protected override void
LoadPlaceholderContentForPresentation(PlaceholderControlEventArgs e)
{
EnsureChildControls();
base.Html =
(((HtmlPlaceholder)(base.BoundPlaceholder)).Html.Replace("<a","<a
target=\"_new\");
}

That should do the job.


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
----------------------


"andrew007" <gah...@yahoo.com> wrote in message
news:C7BDEDA7-48D4-4DE1...@microsoft.com...

andrew007

unread,
Aug 9, 2005, 1:09:13 PM8/9/05
to
Thanks for your reply.
appreciate your help but I deal w/SingleAttachmentPlaceholderControl so ..it
doesn't have html properties (for example base.html don't work) which makes
my life a bit difficult...
I check available properties in this placeholder
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/MCMSSDK02/html/T_Microsoft_ContentManagement_WebControls_SingleAttachmentPlaceholderControl_Members.asp) but didn't find a easy way to implement your solution.

Thanks

Stefan [MSFT]

unread,
Aug 9, 2005, 1:55:23 PM8/9/05
to
Hi Andrew,

then do 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();

string newhtml = orightml.Replace("<a","<a target=\"_new\");

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
----------------------


"andrew007" <gah...@yahoo.com> wrote in message

news:E9C4C8C8-EF99-4A97...@microsoft.com...

andrew007

unread,
Aug 9, 2005, 4:16:47 PM8/9/05
to
Thanks a lot it works perfect..you rocks...
0 new messages