This article is a quick guide to some features of the DNJ framework. DNJ is an Open Source framework that helps using jQuery with ASP.NET applications. It provide helper functions, an AJAX extender, a transparent RPC, and an implementation of the jQuery UI components as ASP.NET web controls.
The idea of developing this framework came to me when I started working with jQuery in my ASP.NET projects. I started using code snippets to create HTML code for tabs, accordion, sliders... then I wrote some helpers to load needed jQuery scripts automatically ...
I noticed that I repeated the same steps in each new project, and I don't think to be the only developer who have done this.
An important point was the Visual Studio designer rendering. When you use jQuery, you have to run you web application to see the effect applied, and this is a big issue when developing complex user interfaces... I thought that having design time WYSIWYG for jQuery controls would help a lot!
In the following article, I will present the implemented features in the current DNJ release (v0.3.5-beta) and how to use them in your projects.
Please note the at this time, DNJ is in beta stage, and need your help to test, identify bugs, and suggest enhancements, so if you find the idea interesting, download the framework and report any bugs or suggestions.
Prepare the environment
Before you begin, you have to download the DNJ framework here. I recommend you to use the Windows installer package; it contains the DNJ runtime DLLs, a VS template project, a VS demo site, the toolbox installer, and the jQuery UI themes that can be used with DNJ! If you don't want to use the Windows installer, you can download each component alone (runtime DLLs / project template / demo site). If you are creating a new project, use the DNJ template to create it. If you want to enable DNJ for a new project, you have to add references to the DNJ runtime libraries (Org.Eurekaa.DNJ.dll and Org.Eurekaa.DNJ.UI.dll). Then, edit your web.config and add the following to the
<add path="DNJResources.axd" verb="*"
type="Org.Eurekaa.DNJ.http.DNJHttpHandler, Org.Eurekaa.DNJ" />
Please note that if you don't add the code above, DNJ will ask you to add it automatically when you first use a DNJ web control.
DNJ scripts loader
One important module in DNJ is the script loader; this module allows you to build a minified jQuery+jQuery package on the fly.
You can easily decide which jQuery plug-ins and which jQuery UI components will be loaded. The script loader is an HTTP handler that you can call in a
The following syntax will load all jQuery + jQuery scripts:
If you need to load only some parts of the jQuery UI for example, you can use this syntax:
and for more granularity you can use this syntax (all possible values are represented):
DNJ RPC module
Let's say you have the following C# class where you declare some functions:
public class ServerProcesses
public static string SayHello()
return "Hello World from : " +
public string Say(string something)
public int Add(int a, int b)
return a + b;
public double Add(double a, double b)
return a + b;
$.DNJRPC('#target').MyNameSpace.ServerProcesses.Say('Some string here');
var a = GetSomeValueForA();
var b = GetSomeValueForB();
$.DNJRPC('#result').MyNameSpace.ServerProcesses.Add(a , b);
Note that the namespace was preserved!
To achieve this, you have to declare the allowed methods in a JSON configuration file (let's say, dnj/config/dnjrpc.conf.js):
Note that for both the C# Add methods, we only declared one entry! The parameters type will be detected automatically.
Click here to see a live example. (See page source for details.)
AJAXify .NET web controls using the DNJ Panel
This module is an AJAX extender that works like the ASP.NET AJAX Panel. The DNJ Panel doesn't need a script manager, and has some callbacks which can be overloaded to customize some behaviours of the panel. The module requires jQuery to be loaded using the DNJ scripts loader.
To AJAXify a standard .NET web control, all you have to do is put it into a DNJ Panel. This will prevent the control from reloading the current page while doing a postback ... check a live demo here: DNJPanel with default settings.
This will work exactly like the Microsoft ASP.NET AJAX Panel. Now, let's see how we can add fun stuff to DNJPanel.
In the .aspx file, we will add the following code:
font:700 11px verdana;
We ask DNJ Panel to overload its before/after/error callbacks. The before and after callbacks will show/hide an indicator like the one used by GMail.
The error callback will use a third party jQuery plug-in (nyromodal) to display the exception screen when an error occurs.
All this is demonstrated in the following page: DNJPanel advanced demo.
DNJ web controls
If you use the Windows installer to setup DNJ, you will get the following toolbox added to Visual Studio (you can get the Windows installer here):
If the installation process fails, you can download the DNJ runtime libraries and add them manually. The controls are all WYSIWYG, but there is still some incompatibilities with VS2005 that will be fixed in the next release. The web control designers are built to keep both the jQuery and ASP.NET logic. In the following screenshot, you can see the DNJTabs controls in the VS designer.
All DNJ UI controls have a common property called "
Settings" which encapsulates all the settings that will be passed to the JQueryUI control.
Note that you can add/modify/remove tab pages using the designer, you can modify the control properties from the Properties box, and you'll see what will be passed to the jQuery plug-in on the fly (the JSON string).
DNJ DatePicker design:
And, here is an example of the ASPX code of a DNJTab component:
runat="server" Height="325px" Width="400px">
<dnj:DNJBox runat="server" Title="Page_0" ID="Page_0">
This is a DNJ Tabs demo<br />
you can Add/Remove/Edit tabs' titles
from the source code or from the designer
<dnj:DNJBox ID="Page_1" runat="server" Title="Page_1">
It works :)
<dnj:DNJBox ID="Page_3" runat="server"
This content will be replaced with the result of an ajax Call
and the source code of the DNJ DatePicker:
<dnj:DNJDatePicker ID="DNJDatePicker1" runat="server">
<Settings AppendText="" ButtonImage=""
ChangeMonth="True" ChangeYear="True" InlineMode="True" />
As you can see, the code is clean ;)
Check the live demo here.
In this article, I tried to give you an idea of what's DNJ and what you can do with it. The project is still in development stage, and needs a lot of enhancements, so feedbacks are welcome. I'm working hard to write a complete documentation for the current release that will be released in the DNJ official website. If you are interested in the project, or have ideas you like to see in future DNJ releases, don't hesitate to comment on this article, or use the Google Code project issue tracker to post them.