Purpose

As mentioned in the previous post, in order to create good client side controls that interact well with the ASP.NET MVC system, we need to have a way to visualize data that the control either generates, or passes to the controllers. I found this difficult to acheive in IE as well as Firefox. I did not need/want all of the complexities of Firebug or IE's Developer tools (which are great btw). I just wanted to see my data! The problem with the previous version of the debugger was that it was too dang simple! If I were to use it like this:

_('Test').clear()
	.write('(Simple)')
	.set(complexArray)
	.write('(Complex Array)')
	.set({ one: { a: 'Hospital', b: 4, c: {x:3,y:5}}, two: 'test'})
	.write('(Complex Object)')
	.set(function(arg) { alert('HI!' + arg); })
	.write('(function)')
	.set({ one: new Array('Happy', 'debugger', 'array'), two: 'test'})
	.write('(Complex Object)')
	.set(
		new Array(
			new Array(
				{a: 1, b: 2, c: 3},
				{a: 4, b: 5, c: 6},
				{a: 7, b: 8, c: 9}), 
			new Array(
				{a: 'one', b: 'two', c: 'three'}, 
				{a: 'four', b: 'five', c: 'six'}, 
				{a: 'seven', b: 'eight', c: 'nine'})))
	.write('(Complex Array)');

});

the debugger would simply not be good enough!

Continue reading Creating Advanced ASP.NET MVC Controls (Part 2, Finished Debugger)

Read more

Purpose

In previous posts, I started creating an html grid helper that was really just an experiment to see how one would accomplish such a thing. Here, I wanted to delve into a more generic approach to creating html controls for the ASP.NET MVC paradigm that would accomplish the following:

  1. be highly interactive on the client side, while
  2. minimizing the client-server interaction

Continue reading Creating Advanced ASP.NET MVC Controls (Part 1, A Debugger)

Read more

The Beef

I've found myself often looking back through old posts (the few I have) and being seriously fed up with the various and sundry cheesy syntax highlighting I had used for code. In that spirit I finally decided to get a proper one. The one I finally decided to use was SyntaxHighlighter written by Alex Gorbatchev. I liked it so much I actually went back to all my previous posts and "corrected" all of the cheesiness. Hoorah!

Lack of Posts

I have been a serious slacker when it comes to posting things! I have not completely finished the MVC Grid I was building. Many have commented that there are other (considerably better) implementations such as that in the MVC Contrib project. The purpose of the series was not to make a grid to end all grids; the purpose was to see if I could do it and learn anything along the way. I will try to get those posts coming again as soon as I get a chance.

Read more

Simple Form Helper

As I continue to use JQuery and MVC I am completely impressed with how much you can do with very little. I know the new preview 4 came out with an AjaxForm helper. I could not resist, so I made my own and added it to the whole controls project I've been working on. (I have not forgot about the grid, but I've gotten a little bored of it for the time being although I do want to finish it...). So here is the idea:

  1. Have complete control over HOW the form is rendered
  2. Be VERY light (I attached the whole thing to the onSubmit attribute on the form)
  3. Make it fast (it took me like a half an hour or so)

Continue reading JQuery MVC Form Helper

Read more

Well, I finally upgraded to BlogEngine.NET 1.4 (patch and all). It took about 40 minutes or so (I was overly cautious of course). I am currently using SQL Server as the provider. Thanks to Al Nyveldt everything went smoothly. Overall, I like the widgets on the side. Everything else seems to be about the same (again I just finished installing). So far I like what I see!

Read more

Moving away from ASP 3.0 Request.Form(" ...

As mentioned in my previous post, I wanted to find a way to auto-populate and entity object from the Request.Form collection. I also wanted (as an aside) to see if the grid still worked on MVC Preview 4 (it does). Here is the code:

public static T Request<T>(this Controller controller) where T : class, new()
{
    T o = new T();
    var request = controller.Request;
    foreach (var property in typeof(T).GetProperties())
    {
        // Check if the object has the appropriate property
        var q = (request.Form.AllKeys
            .Where&lt;string>(s =&gt; s.ToLower() == property.Name.ToLower()))
            .ToList&lt;string>();

        // if more than one... ignore
        if(q.Count == 1)
        {
             string datum = request.Form[q[0]];
             if (property.PropertyType == typeof(string))
                 property.SetValue(o, datum, null);
             else
                 property.SetValue(o,
                    Convert.ChangeType(datum, property.PropertyType),
                    null);
         }
    }

    return o;
}

Continue reading MVC Form Helper

Read more

Moving to an HTML Helper

As I was looking around at the various HTML helpers out there, I realized that I should probably conform and stick to what is being done. Having said that, I refactored the Grid class to be a new HTML helper. Here is how it is used (similar to an MvcForm<T> actually):

<% using (Html.GridControl<StudentController, StudentEntity, int>(
   s => s.EditStudent(), 
   s => s.DeleteStudent(), 
   ViewData.Model, 
   s => s.StudentId, 
   "Student",
   null)) {  %>
Special text here!
<% } %>

Continue reading Ajax HTML Grid Control for ASP.NET MVC (Part 3)

Read more

Preamble

Over the long weekend I thought a lot about where I wanted to go with the grid "control" for ASP.NET MVC. One of the things that weighed heavily on my mind was the ability to have the control fully customizable. As I thought about this, I decided that first thing's first: I need to get the functionality working and then worry about the prettiness factor. So for those of you concerned about the customizability - it's coming. For now, I really want to focus on the ability of the grid to get work done.

Continue reading Ajax HTML Grid Control for ASP.NET MVC (Part 2)

Read more

At work we are starting a major project and I think we have decided to go the ASP.NET MVC route. One of the concerns we had was that we could not use traditional "web controls" (i.e. Telerik, DevExpress) since the all require the <...runat=server> portion. With that said, I thought I would start to take a look at how I would go about doing it! The first "control" I want to get off the ground is a data bound grid that allows asynchronous saves via JavaScript. We'll see how it goes!

Continue reading Ajax HTML Grid Control for ASP.NET MVC (Part 1)

Read more