As I've been reading through the comments to my last post it occurred to me that .NET has been around for about 7 years now, and for a lot of developers, that's all they know. The WebForm model has been accepted and adopted as "just the way you do it" and is unique to Microsoft. Sometimes it makes sense, sometimes not.
Josh Stodola left a good comment on my last post, and in part he asked:
In your example, what would you do about an edit or delete button?
I stumbled a bit when coming up with a response... I just wasn't sure what he meant! In my mind I was thinking "is he talking about a link button? A submit button? An embedded button in the grid?" and I had a really weird sense of Vertigo (I hear they're hiring btw)...
This isn't a negative response to Josh - just a musing on things he made me think about when reading his comment.
It's About Text
In his talk at MIX 07, Anders Hejlsberg had this to to say about web programming:
"It's only text... right? I mean sometimes we forget that..."
I think that's a really valuable thought: We're Text-Slingers, herding HTML using the HTTP protocol, over the TCP/IP trails...
HTML is pretty simple stuff, and it was abstracted into the WebForm paradigm so that Microsoft could wrap the "Visual Programming" approach together into Visual Studio (drag and drop on a control surface). The concept is powerful, as we've seen. ASP.NET is good stuff all around and really lends itself to rapid programming.
To me, the most powerful feature of .NET is the backend stuff - using full-featured C#, managed code, ADO.NET, etc. It's not the designer.
Indeed one of the "issues" with WebForms is that this model (Visual development with Code-behind) sometimes just doesn't fit for what we're doing. Consider the CSS limitations of the GridView, the inability to do rollups, the generated "style=width:320%" when you want the columns to flow, etc. Without getting negative, let's just leave it at the statement that the designer has had it's issues :).
Some commenters on my last post mentioned that "I used HATE inline scripting until I tried Rails". I had that same experience as well. I invite you to think about this a bit more (if you're in the "scripting blows" camp)...
Forms and the Kitchen Sink
I want to answer Josh RE "what would you do about an edit or delete button" with as thoughtful an answer as I can (it was too big for a comment. Using the new MVC framework (or currently using Rails), I can embed a form (if I had to use POST- note that I don't need to do this if I use GET) :
<table> <tr> <td>Option</td> <td>ID</td> <td>Product</td> </tr> <% //same method used for the ODS Northwind.ProductCollection products = new Northwind.ProductController().FetchAll(); foreach (Northwind.Product p in products) { %> <tr> <td> <a href="MyEditPage.aspx?id=<%=p.ProductID.ToString()%>">Select</a> <form action="MyActionPage" method="POST"> <input type="hidden" name="productID" value="<%=p.ProductID.ToString()%>" /> <input type="submit" value="Delete" /> <input type="submit" value="Edit" /> </form> </td> <td><%=p.ProductName%></td> <td><%=p.ProductID.ToString()%></td> </tr> <%} %> </table>
This type of thing isn't possible using ASP.NET since we have a single form per page (the Kitchen Sink Approach)- embedded forms don't work. This isn't the way HTML was intended to be used (no judgement here - just pointing this out).
Some might think this is "Ugly" - I can understand that. But consider that it's not really ugly - it's just not what you're used to. To others (non-ASP programmers), the ViewState is the definition of ugly.
I don't want to get into a ViewState debate - I just want to point out that more control over your HTML can make your presentation much more powerful and enjoyable to create.
