Does Razor syntax provide a compelling advantage in UI markup?

[Disclaimer: I’m one of the Microsoft developers on MVC and Razor, so I might be a bit biased :)] We designed Razor to be a concise templating language that uses only the minimal necessary amount of control characters. I would say that large parts of your views can be expressed with fewer characters than the … Read more

Can Microdata be applied on any type of HTML element? [closed]

You can use every HTML5 element for Microdata … Microdata defines 5 new attributes for HTML5: itemid itemprop itemref itemscope itemtype Let’s see where they can be used. Section 5.2 says: Every HTML element may have an itemscope attribute specified. So every element can have itemscope. Further on it says: Elements with an itemscope attribute … Read more

Truncate text containing HTML, ignoring tags

Assuming you are using valid XHTML, it’s simple to parse the HTML and make sure tags are handled properly. You simply need to track which tags have been opened so far, and make sure to close them again “on your way out”. <?php header(‘Content-type: text/plain; charset=utf-8’); function printTruncated($maxLength, $html, $isUtf8=true) { $printedLength = 0; $position … Read more

How to make PDF file downloadable in HTML link?

This is a common issue but few people know there’s a simple HTML 5 solution: <a href=”https://stackoverflow.com/questions/364946/./directory/yourfile.pdf” download=”newfilename”>Download the pdf</a> Where newfilename is the suggested filename for the user to save the file. Or it will default to the filename on the serverside if you leave it empty, like this: <a href=”https://stackoverflow.com/questions/364946/./directory/yourfile.pdf” download>Download the pdf</a> … Read more