Here’s an idea I’ve been working on for a little while, and I think is now ready for others to use – a client-side MVC engine that slots into existing ASP.NET pages and makes it dead easy to make dynamic user interfaces.
By that, I mean UIs where the set of controls changes according to the data entered or selections made. Controls appear or disappear, enable or disable, highlight or animate, as the user interacts with them.
Impatient? Start by checking out the demos
Imagine you’re writing a blog application in which the user can enter a list of “tags” for each entry. You could ask them to enter a comma-separated list of strings in a single textbox, but that’s not very nice. It’s better to present a list of separate textboxes – but how many? Well, that isn’t determined in advance, so you’ll need to offer a variable number. Is that so hard?
In standard ASP.NET, despite the simplicity of the requirements, it is painful.
With a jMVC.NET control, it’s easy and clean – your server-side code looks like this:
That’s all there is to it on the server. Assign the data to the control, then read back the results – there’s no intermediate processing or manipulating of controls.
Your code in-front looks like this:
… and you have a view template like this:
It’s very clean and direct, and you get a control tree that changes and updates right there in the browser with no server communication. Each time the user clicks “add” or “delete”, the underlying data model is updated, and the jMVC framework rebuilds the UI to match.
Installation and Usage
Installation consists of dropping the two DLLs into your /bin folder:
To add a control to your page, register the jMVC namespace in your ASPX file:
Add a MVCPanel control wherever you want it:
You need to add a view template – usually given the .jmvc extension but anything else if your web server won’t serve files with a .jmvc extension. It’s a plain text file, following the jMVC syntax described here.
Finally, assign data to the control’s “Model” property, and read it back after a postback.
Those short instructions hardly explain the full picture, so it’s best to look at the demo website. This outlines some realistic use cases and lets you see the source code.
If you have questions or feedback, please post a comment and I’ll reply as soon as I can.
The demo website also has the latest download information, including information on accessing the public subversion repository.
jMVC.NET is provided under a MIT license, so you can use it in commercial or non-commercial projects.
On the server, you need to run ASP.NET 2.0 or higher. Browser compatibility is most modern browsers, certainly including IE6+ and Firefox 2+.