Right now we are using the Winnovative PDF Converter software to create some reports. It’s a great tool that allows us to create a page in HTML then when we want to print it we just change it slightly to pull off the elements that should not be in the report.
Month: February 2014
JavaScript Tips n Tricks: Writing Decent JavaScript Code
I’ve had a hard time learning JavaScript over the years. Mainly because I only learn it as I need to use it and most of the code I use is what I find doing a search for a single specific topic. One of my goals last year was to improve these skills. A new SPA project at work has helped me quite a bit but I keep looking for better information. Someone had recommended the book “JavaScript the Good Parts” by Douglas Crockford. I picked it up, read the intro, paged through it a few times, and promptly forgot I had purchased it. A few days ago I was looking at Pluralsight to find something new to watch and found out that there was a new course called “JavaScript the Good Parts” out there authored by none other than Mr. Crockford himself. I watched it and realized that it was the piece I was missing. Between the book and the course I have finally found both pieces of the puzzle that is JavaScript. I’ll be watching the course a few times to try to catch more of the nuances of the language that have evaded me.
ReportViewer: Display text as bold using HTML markup
I am trying to display a single word inside a larger text area as bold. (Silly requirements.) I have not been able to figure out if there is a way to do this within a standard express. So far all my research has turned up is that I should try to turn markup on for that text box and use HTML markup. Although, even that only has a limited set of supported tags.
First I needed to turn markup on for the textbox. Here are the instructions I found on this asp.net forum answer.
- If the Toolbox is not visible, click Toolbox on the View menu.
- Double-click or drag a Textbox report item to the design surface.
- Drag a field from your dataset into the text box. A placeholder is created for your field.
- Right-click the placeholder (<>), and then click Placeholder Properties.
- On the General tab, verify that the Value box contains an expression that evaluates to the field you dropped in step 3.
- Click HTML – Interpret HTML tags as styles. This causes the field to be evaluated as HTML.
- Click OK.
To manually change it without using the UI tools add the tag “HTML” into the xml.
Finally, I rewrote the text in the textbox to be formatted with html instead of the rdlc formatting. It was a pain to do but in the end will be more flexible and maintainable.
C# Tips n Tricks: Get Decimal Places
I needed a quick way to get the number of decimal places on a Double value. I am displaying the values differently if they have more than 2 decimal values. Here is a quick helper that I threw together.
public static int GetDecimalCount(this double value)
{
var str = value.ToStringOrEmpty();
if (!str.Contains("."))
return 0;
return str.Substring(str.IndexOf(".") + 1).Length;
}