Category Archives: html

Self closing iframe tag fails Javascript execution

On a project I am currently working on, I have to use an iframe. Since I included the iframe in my web application, the Javascript code beneath it stopped working immediately. I did not see the problem at first and had a tough time finding out the iframe caused the problem. As it were, I used a self-closing iframe. The solution to the problem was to add a closing iframe tag instead of using a self-closing iframe… Simple solution, but I assume more people will face this problem as I did ;) .

Happy coding!

How to insert blank rule (<br />) from C# code

Once in a while I have to develop custom user controls that require blank rules in them. Almost always I think again: ‘I should have blogged about it, would have saved me lots of time searching’ :) … Well, no more, because here it is…

Many people using blank rules in C# code, use the following commands:

var brControl1 = new HtmlGenericControl { InnerHtml = "<br />" };
var brControl2 = new HtmlGenericControl("br");

However, brControl1 also prints a <span> tag and brControl2 prints <br></br>. Both options are not really useful. You should take notice of the fact that the HtmlGenericControl is not meant to be used for anything else than span, body, div and font (what is designed for ‘as the word goes’).  The way to go when printing a blank rule is:

var brControl3 = new LiteralControl("<br />");

This actually prints exactly what you would like it to print, namely <br />. Hope this helps you too :) ! BTW, if you are using the HtmlTextWriter class, you can also use the WriteBreak() function if you like.

HTML rounded corners without images and div nesting

Yesterday I had troubles to get an ASP.NET control to work with rounded corners in various browsers. IE and Firefox operate slightly different from each other, and to get it working (using ASP.NET themes) was quite a pain in the ass. Besides, it is not cool to have the obligation to change 4 images per control every time the design team has the bright idea to change website colors for some very good reason.

Luckily, at the end of the day, I discovered DD_roundies, a Javascript library perfectly taking care of my needs. Only in Opera this functionality does not function as wanted (no rounded corners), but that’s an issue Drew Diller is trying to address, according to his website. I definitely would suggest you to try for yourself if you would like an acceptable solution to the problem described hereabove.

The only thing that does not currently stop bothering me: unfortunately it is (still) not possible to have some javascript in an ASP.NET theme. Would that be possible, the solution would be perfect (for me). Perhaps somebody found a solution for me :P ?