BlueDragon Blog
Here you'll find tips and information about making the most of BlueDragon, which offers several compelling implementation alternatives for your CFML applications. This blog was created originally by Charlie Arehart, who was New Atlanta CTO from 2003-2006.,He has since moved on to become an independent consultant but continues to answer comments raised in existing blog entries. BlueDragon continues, and you should look to the newer BlueDragon blog, from New Atlanta president, Vince Bonfanti, for more updated information.

BlueDragon Advantage - Calling CFCs from ASP.NET pages

posted Tuesday, 21 December 2004

As you explore the implementation of BlueDragon on .NET, you'll learn that just as CF and BD allow tight integration with Java components in their respective Java-based editions, only BlueDragon allows you to call a CFC from an ASP.NET page. Yep, you heard that right. Consider the following code from VB.NET page:

<%
        DIM Employees AS CfComponent = CreateComponent( "employees" )
        DIM getExp AS System.Data.DataTable = Employees.Invoke( "getemployees" )
%>

What this is doing is invoking an employees.cfc (in this case, presumed to be in the same directory as the ASPX page making the call). The next line shows invoking the getemployees method, and it happens to return a CFQUERY result.

The cooler thing is that you see that this resultset can be treated in the ASPX page as a .NET datatable. So what, you wonder? Well, if it's a datatable, then you can do with it whatever one normally does with such recordsets in a .NET page....like bind it to a data grid? Sure! Here's the full page:

<%@ Page Language="vb" Inherits="NewAtlanta.BlueDragon.CfmPage" %>
<%@ Register TagPrefix="cf" Namespace="NewAtlanta.BlueDragon" Assembly="BlueDragon.Controls" %>

<%
 DIM Employees AS CfComponent = CreateComponent( "employees" )
 DIM getExp AS System.Data.DataTable = Employees.Invoke( "getemployees" )
 grid.DataSource = new System.Data.DataView( getExp )
 grid.DataBind()
%>

<asp:DataGrid runat="server" id="grid" BackColor="#eeeeee" Width="85%" 
         HorizontalAlign="Center" Font-Name="Verdana" Font-Size="10pt">
  <HeaderStyle BackColor="Black" ForeColor="White" Font-Bold="True" HorizontalAlign="Center" />
  <AlternatingItemStyle BackColor="White" />
</asp:datagrid>

An example of the output from this is shown below:

.NET DataGrid From CFC Invocation
This certainly opens the doors to many very interesting aspects of leveraging .NET features alongside your CFML.

For more details on the directives and custom objects used in the code above, look for the updated BlueDragon .NET documentation coming in Release Candidate 1 (in January). You can use this code now with the beta 1. This particular concept just is not documented there yet.

Other features of leveraging CFML and .NET are documented there, and I'll highlight more of these in upcoming entries. If you want to get started, go download it, and/or read the current version of the manual.




1. a reader left...
Tuesday, 21 December 2004 8:29 pm

this is pretty cool.

Adedeji Olowe [adedeji@olowe.com]


2. a reader left...
Wednesday, 22 December 2004 9:59 am

A minor point: the Register directive for the BlueDragon.Controls library isn't needed in this example (though it doesn't hurt). Use of the BlueDragon.Controls library for further integration of CFML and ASP.NET is a good subject for future blogs. :-)

Vince Bonfanti [vince@newatlanta.com]