Blog Home  Home RSS 2.0 Atom 1.0 CDF  
Ruminations of a Developer - Tuesday, February 21, 2006
Mark Bonafe
 
 Tuesday, February 21, 2006

I just read a very nice article on ASP.NET Best practices by Ali Khan.  It covers some items that most .NET developers should know by heart and others that we do know but sometimes forget.

The only thing I can find to disagree with is tip number 15.  It talks about using stored procedures instead of "ad-hoc" queries.  The speed benefit of this approach has met skepticism lately by numerous developers.  I definitely fall into this category.  I prefer keeping the maintenance of queries outside of the database.

2/21/2006 9:28:07 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0]    |  Trackback
 Monday, February 20, 2006

So now you have a nice report written to an HTML file.  How do you open it for the user to view it using IE?  You could try this:

System.Diagnostics.Process.Start("iexplore.exe","MyReport.htm");

But this hasn't always worked for me.  Here is a sure fire way to put it all together.

Add a project reference to the COM library, Microsoft Internet Controls.  Add these two using statements:

using SHDocVw;
using System.Runtime.InteropServices;

Where you need to open the browser, add the following code:

explorer = new InternetExplorer(); 
if (explorer != null

     explorer.Visible = true
     object x = null;
     explorer.Navigate(@"MyReport.htm
", ref x, ref x, ref x, ref x); 
}

Thanks to a good friend of mine, Micheal Beall of Overdrive Technologies, for helping me with this.

***Originally posted on DotNetJunkies on February 16, 2005

2/20/2006 2:10:49 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0]    |  Trackback

Printing a web page that represents a report has been difficult for me in the past.  I want to print a header and/or a footer that repeats on every printed page.  The screen version certainly isn't paginated, so how can you print a good looking report?  Style (or CSS) to the rescue. 

Put the following Style tag, or something similar, in the header of the page.

<STYLE TYPE=”text/cssMEDIA=”screen, print>
<!--
TABLE {
  table-layout: fixed;
  border: 0;
  cellspacing: 1;
  cellpadding: 1;
  font-family: Arial;
  font-size: 8pt;
  }
TH {
  font-family: Arial;
  color: black;
  background-color: lightgrey;
  text-decoration: underline;
  }
THEAD {
  display: table-header-group;
  }
TFOOT {
  display: table-footer-group;
  }
-->
</STYLE>

Since nearly every report uses an HTML Table, this works very well.  The THEAD and TFOOT styles is what makes the table a report.  If you don't want to setup a style tag, you can enter the style right into the table.

<table style="table-layout:fixed">
    <colgroup>
        <col width="150"/>
        <col width="100"/>
        <col width="150"/>
    </colgroup>
    <thead style="display:table-header-group">
        <tr>
            <td>Header column 1</td>
            <td>Header column 2</td>
            <td>Header column 3</td>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>Body column 1</td>
            <td>Body column 2</td>
            <td>Body column 3</td>
        </tr>
    </tbody>
    <tfoot style="display:table-footer-group">
        <tr>
            <td>Footer column 1</td>
            <td>Footer column 2</td>
            <td>Footer column 3</td>
        </tr>
    </tfoot>
</table>
 
Sounds too easy to be true but it works very nicely.  Of course, adding more style (bolding, underlining, background and foreground colors, etc.) makes this a very nice reporting option.

***Originally posted on DotNetJunkies on February 16, 2005

2/20/2006 2:08:19 PM (Eastern Standard Time, UTC-05:00)  #    Comments [1]    |  Trackback

After examining numerous articles on printing with C#, I was about ready to toss in the towel and just copy & paste to Word (yuck).  Then I found How To Print the Content of a RichTextBox Control By Using Visual C# .NET on Microsoft's support site.

I was sure that printing a RichTextbox should be pretty easy.  All the articles made it very difficult, though.  This article shows the “correct” way to print.  The entire contents are printed; pictures, other graphics, colors, etc.

***Originally posted on DotNetJunkies on January 11, 2005

2/20/2006 2:05:53 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0]    |  Trackback
 Sunday, February 19, 2006

Welcome to my developer blog!  The entries here will focus on my experiences and thoughts as a software professional.  The first entries will be transferred from my first blog on dotnetjunkies.  I haven't posted there for quite a while.  I will post on a variety of topics; coding tips, interesting articles, cool products, project methodologies, etc.  If it has anything to do with software development, I'll be talking about it here.

My writing style is to be straight forward, sometimes from the hip.  I can be hard on others at times.  But I can also be very gratious when I find or read something with which I like or agree.  I can dish it out and I can take it.  If you read anything here that you agree, or disagree, with, please let me know.  I don't take things personally. 

Conversation, including an occasional heated disagreement, is great for the mind.  It solidifies your character.  So let's get started...

2/19/2006 12:05:13 PM (Eastern Standard Time, UTC-05:00)  #    Comments [2]    |  Trackback
Copyright © 2010 Mark Bonafe. All rights reserved.