Justin Cooney

Web Development Tips and Examples

  • ShowModalDialog Example
    ShowModalDialog Example

    Using the JavaScript showModalDialog function is a useful way for Web developers to create a modal popup. Unlike other popup functions, the showModalDialog function makes use of two separate HTML pages… one page as the parent page, and one page as the content of the modal dialog.

    Developers will sometimes want the modal popup to be more than just a fancy version of the common alert() function. In this case, one has the option of creating a fully functional Web form in the Web page called from the showModalDialog function.

    (more…)

  • By definition, a scalar query will return the first column of the first row of a database query. In plain English this means it will return a single value.  This can come in handy at times.

    In the next series of articles I will cover the basic data connections including basic examples in C# and VB.NET.

    One thing to note from the examples below is that I am using a try – catch – finally syntax to handle the clean-up of the command and connection objects. As an alternate syntax, you can make use of the Using object to handle the cleanup.

    (more…)

  • In the example functions below I’m illustrating how to set up a basic query to a stored procedure in your database that takes a single string parameter. The examples involve using the SQLDataAdapter object to Fill a DataSet. The resulting DataTable can then be queried as desired. Specifically:

    1. The first example shows how to read the first row of the results after your Datatable has been populated. I provide the same example in VB.NET and C#.
    2. The second example shows how to loop through the results if you anticipate multiple returned rows. As before,  I provide the same example in VB.NET and C#.

    As part of this code, remember to include the correct .NET Namespaces. If you are writing your code inline (in either VB.NET or C#), use:

    <%@ Import Namespace="System.Data" %>
    <%@ Import Namespace="System.Data.SqlClient" %>

    and if you are writing your code in codebehind, use:

    VB Codebehind:

    Imports System.Data
    Imports System.Data.SqlClient

    C# Codebehind:

    using System.Data;
    using System.Data.SqlClient;

    Also, navigate here if you are interested in further articles I have written about ADO in .NET.

    (more…)