Monday, July 16, 2012

single quote versus backslash double quote

In HTML code behind, we tend to use single quotes to indicate the ID of an html object. But the best practice that we need to know is to always use backslash double quote. This is being parsed by all kinds of browsers (even IE 6 or other lower versions of browsers). The single quotes are only read by new browsers so we might be confused why our code has browser compatibility issues. Sharing is caring!

How to read html objects after rendering

This is how to read html objects after rendering: var elements = $('.item-class'); The .item-class is a css class inside a div. After that, we can now use: for (var i = 0; i < elements .length; i++) { var it = document.getElementById("id_" + i).innerHTML.split(' - ')[1].replace('%', ''); } This is getting the HTML data of all the objects inside the page with item-class css. Then, I used Split to separate the Label from the Percent, then replace the percent symbol to get the number inside. Hope you understood what I explained. Keep fighting!

Wednesday, February 8, 2012

MS Reporting

Create a new Web Application Project.

Add a new item -> Reporting -> Report.rdlc




Drag a ReportViewer control from Toolbox to a Web Page.




Make sure to include ScriptManager on the web page.

Set the datasource and design the report.

Tuesday, February 7, 2012

Ellipsis in Silverlight

Before, when we want to display a long string in a Silverlight page, we create StringConverter just to cut the string and add ... or ellipsis at the last part. Now, we just use this:

<TextBlock Text="the quick brown fox jumps over the lazy dog" TextTrimming="WordEllipsis"/>

This will let the silverlight check the width of the holder of the text then cut the text and add ... or ellipses at the end.

Nice additional feature of Silverlight.