V
VR
Hi, I'm developing a Web Custom Control and I'm facing some problems with
HTML tags that do not have a closing pair (like <br>,<img>).
Let's say I have a loop that create <div> tags and inside it I put some text
and images:
output.renderBeingTag("div")
output.write("some text")
output.renderBeingTag("br")
output.addAttribute("src","myImage.jpg")
output.renderBeingTag("img")
output.renderEndTag() 'img?
output.renderEndTag() 'br?
output.renderEndTag() 'div?
if I use this code, in IE all goes fine, but when I look in the HTML source
code generated by the control I found that I have <img src="myImage.jpg" />
and <br />. Isn't this bad HTML? Will it work on all browsers as MS says?
(It's not surprise that IE interprets it the right way - almost all bad HTML
IE fix it before rendering the screen).
If I remove the renderEndTag() for <br> and <img> all <div> tags start
getting nested one inside another (that's not what I want)
Well, for all tags that do not really have a closing pair I started using
code like output.write("<br>") and, of course, I'm loosing some ASP.Net
functionality, but, can anyone say if it is really the best approach?
Thanks a lot,
Victor Reboucas
HTML tags that do not have a closing pair (like <br>,<img>).
Let's say I have a loop that create <div> tags and inside it I put some text
and images:
output.renderBeingTag("div")
output.write("some text")
output.renderBeingTag("br")
output.addAttribute("src","myImage.jpg")
output.renderBeingTag("img")
output.renderEndTag() 'img?
output.renderEndTag() 'br?
output.renderEndTag() 'div?
if I use this code, in IE all goes fine, but when I look in the HTML source
code generated by the control I found that I have <img src="myImage.jpg" />
and <br />. Isn't this bad HTML? Will it work on all browsers as MS says?
(It's not surprise that IE interprets it the right way - almost all bad HTML
IE fix it before rendering the screen).
If I remove the renderEndTag() for <br> and <img> all <div> tags start
getting nested one inside another (that's not what I want)
Well, for all tags that do not really have a closing pair I started using
code like output.write("<br>") and, of course, I'm loosing some ASP.Net
functionality, but, can anyone say if it is really the best approach?
Thanks a lot,
Victor Reboucas