Justin Cooney

Web Development Tips and Examples

  • iTextSharp PDF
    Using iTextSharp to Generate a PDF

    This article will review the basics of programmatically inserting and positioning an image in a PDF being generated using the iTextSharp library. I’ll show you the code for doing so in both C# and VB.NET.

    Here are the main categories I’ll be covering, with links to the appropriate section:

    1. Adding your image programmatically while generating your PDF
    2. Adjusting your image scaling so it renders nicely in your PDF
    3. Positioning your image in your PDF
    4. Example code in C#
    5. Example code in VB.NET

    If you are interested in working with the iTextSharp .NET libraries then have a look at some of the other articles covering iTextSharp I have written on the topic. (more…)

  • T-SQL Example
    T-SQL Example

    In this article  I will expand on an article I wrote earlier about how to search through all of the columns in each table in your database for a particular piece of information.

    In the example in this article I have:

    1. Modified my previous example query to search through columns of all datatypes rather than just VARCHAR type columns. This is important since often tables will have columns consisting of custom datatypes or possibly even Int value columns depending on your search.
    2. I’ve changed what is output to be the distinct table name and column names that contain the information you are looking for. You’ll be able to take useful looking results from this overview information and then run detailed queries to find out more.
    3. Also, I have modified the original query to do an exact match for the data being searched for rather than a LIKE condition. If you would like to change this back to a LIKE condition, then I have highlighted the relevant section in red that you can replace with the LIKE condition example in my previous article.This exact match is useful in particular if you are looking for an identity key value throughout your database such as: show me the user Jim who has an ID of 56 so that I can track down all instances of his account information in our database.

    (more…)

  • ASP.NET
    ASP.NET

    It’s a common requirement when developing Web applications to need to programmatically find out the name of the running Web page.

    In this article I will look into some of the basic commands in ASP.NET that you can use to find the name of the Web page that is currently running the script. As part of this process I will also cover some of the typical component parts of a URL that you may have to deal with.

    For clarity I’ll review the same commands in both C# and VB.NET.

    In both VB.NET and C# you can find the current page name using:

    • System.IO.Path.GetFileName
    • System.IO.FileInfo
    • System.Web.VirtualPathUtility.GetFileName

    If you find this article useful, check out some other ASP.NET tips I have written. (more…)