Server.HtmlDecode Question
am 05.01.2008 21:10:43 von Reformed Dem
I'm trying to put an image tag inside of an anchor tag that I plan to
dynamically add to a place holder tag.
The trouble is, though, that the "<" character is showing as "<" and the
">" as ">". Is there a way to get these show correctly on the html page?
Thanks in advance!
C# Code
System.Web.UI.HtmlControls.HtmlAnchor hMenuHome = new HtmlAnchor();
hMenuHome.ID = "hMenuHome";
hMenuHome.HRef = "default.aspx";
hMenuHome.InnerText = Server.HtmlDecode("<") + "img name=\"n_home\"
src=\"images/n_home.gif\" width=\"202\" height=\"50\" border=\"0\"
id=\"n_home\" alt=\"Home\" /" + Server.HtmlDecode(">");
hMenuHome.Attributes["onMouseOut"] = "MM_swapImgRestore();";
hMenuHome.Attributes["onMouseOver"] =
"MM_swapImage('n_home','','images/n_home_f2.gif',1);";
phMenuHome.Controls.Add (hMenuHome);
Resulting Html Code
onMouseOver="MM_swapImage('n_home','','images/n_home_f2.gif' ,1);"> <img
name="n_home" src="images/n_home.gif"
width="202" height="50" border="0"
id="n_home" alt="Home" />
Re: Server.HtmlDecode Question
am 06.01.2008 01:19:30 von Reformed Dem
"Night Air" wrote in message
news:4vRfj.3024$pr6.195@nlpi070.nbdc.sbc.com...
> I'm trying to put an image tag inside of an anchor tag that I plan to
> dynamically add to a place holder tag.
>
> The trouble is, though, that the "<" character is showing as "<" and
> the ">" as ">". Is there a way to get these show correctly on the html
> page?
>
> Thanks in advance!
>
Nevermind -- I found the problem.
I was using InnerText instead of InnerHtml.
Problem solved.
Thanks anyway!
Re: Server.HtmlDecode Question
am 16.01.2008 16:36:45 von jordan.houari
On 6 jan, 01:19, "Night Air" wrote:
> "Night Air" wrote in message
>
> news:4vRfj.3024$pr6.195@nlpi070.nbdc.sbc.com...
>
> > I'm trying to put an image tag inside of an anchor tag that I plan to
> > dynamically add to a place holder tag.
>
> > The trouble is, though, that the "<" character is showing as "<" and
> > the ">" as ">". Is there a way to get these show correctly on the html
> > page?
>
> > Thanks in advance!
>
> Nevermind -- I found the problem.
>
> I was using InnerText instead of InnerHtml.
>
> Problem solved.
>
> Thanks anyway!
Yes, and for information Server.HtmlDecode("<") will not produce
anything good.
For html decoding you have to put HTML in it. And "<" by its own is
not HTML