I have been getting more and more sick of all the quirks about control ids, trying to get your data in serverside (based on client-side events). I seem to spend more time fighting with controls in asp.net, that I think it takes me more time than I gain by using it.
I was thinking about using plain html/javascript with jQuery and a web service that returns json for the data.
The only thing I think I would miss from webforms is the MasterPages, the session management, authentication based on windows login and possibly validators(although they have some quirks too). (In fact, maybe not for sessions and auth, but I have never developped webservices)
Please, also take note, that I only have the Framework 2.0 available for development.
Edit: The kind of things giving me troubles in asp.net that makes me wonder for the switch:
Here is a sample of a page giving me problems.
There is a tree table (master / details)
You can edit fields on each child row.
When you press the save button, the data from the group row must be updated (just data from a select, no modification in database), as the data from the child row.
I don't want to refresh the whole page because the displayed records are based from search criterias.
The Master / Details are generated using Repeaters
Trying to update a record from code behind is really quirky, and still have no clue about updating the display.
Using jQuery and a web service, my guess would be that i could update directly to the database, request what I want to be displayed and just update that record. This is the kind of things that make me wonder if asp.net is just getting in my way.
________________________________________________________________________ | - Some Details About Group | |________________________________________________________________________| |¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯| | ChildRecord Some Editable Fields SaveButton | | ChildRecord Some Editable Fields SaveButton | | ChildRecord Some Editable Fields SaveButton | | ChildRecord Some Editable Fields SaveButton | |_______________________________________________________| ________________________________________________________________________ | + Some Details About Group | |________________________________________________________________________| ________________________________________________________________________ | + Some Details About Group | |________________________________________________________________________|
Edit2: The problem I have about ASP.NET is not related to ajax. Yes, I use jQuery to make the interfaces more dynamic like showing / hiding the search section when not needed and collapsing details from the tree, but this is all I do with it.
What bothers me is that if I want to check which button has been clicked in this example, I have to use some tricks that feel a bit haky.
If you want to use databound comboboxes in a repeater, you have to use codebehind to set the selected value, it will be a pain to retreive the data selected.
Next, if you want to check what data was modified, you have to save the datatable in the viewstate, read data from all controls in the repeater, then compare with the datatable to make an update. This is this kind of things that bother me with asp.net.
If used properly, ASP.NET and JavaScript/jQuery web applications really can compliment each other. I have now implemented jQuery in 3 different web applications and am loving every minute of it. So long as you use each component to its strength, you'll end up being happy with the project in the end.
You specifically mentioned that Control ID's were causing a problem, but its really not that big of a deal.
JavaScript
document.getElementById("<%=this.MyObject.ClientID %>");
jQuery
$("#<%=this.MyObject.ClientID %>")....
In your example of a parent child relationship, you can very easily handle exactly what you are discussing with ASP.NET and the AJAX framework with UpdatePanels.
You don't have to give up everything, like MasterPages. You might try to turn off ViewState, turn off EventValidation and use as little ASP.NET controls as possible (basically - if some functionality can be easily achieved with XHTML, write it as XHTML). You can still use ASP.NET controls where you need them.
I think that you're not alone. After two years of working with WebForms I also got tired of them and after I discovered how wonderful jQuery was and how well it worked with web services I vastly changed my development model. I am slowly moving towards MVC right now, as I find it the ultimate solution, but for some other apps (small and/or targetting 2.0) I just try to use less server controls, get rid of ViewState, use more AJAX (web services). It works fine. I'd recommend Dave Ward's Encosia - start with this article. I admit it opened my eyes on some other ways to developing web applications using .NET Framework. Good luck!
I think the fundamental question to ask yourself is:
Am I using the controls for what they've been designed to do?
Having worked solely with ASP.NET in the 2.0 Framework, I've found I have not had to deal with the issues you are describing. ASP.NET can be quirky yes, but mostly when you use it for something other than it was intended. In which case custom rolled controls fill the niche easily.
Edit:
Your troubles sound like you're trying to implement AJAX techniques, however in your question you don't mention using the AJAX framework. Have a look at that as it may be able to fill your niche.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With