The advantage of switching from ASP.NET to HTML / jQuery bread and butter

I was sick more and more from all the quirks about control identifiers, trying to get your data on servers (based on events on the client side). I seem to spend more time struggling with controls in asp.net, which, in my opinion, I need more time than I get using it.

I was thinking about using simple html / javascript with jQuery and a web service that returns json for data.

The only thing I think I would skip from webforms is MasterPages, session management, Windows login authentication, and possibly validators (although they also have some quirks). (Actually, maybe not for sessions and auth, but I never developed web services)

  • Something is wrong with this. I think about it or what I did not think about?
  • Are there any things in asp.net that you think I will skip?
  • Has anyone done this before and wants to share the experience?

Please also note that I only have Framework 2.0 for development.


Edit: Something like the problems causing the problems in asp.net makes me wonder about the switch:

Here is an example of a page giving me problems.

There is a table of trees (master / details)

You can edit the fields in each child row.

When you click the save button, the data from the group row should be updated (just the data from the selection, no changes to the database), since the data is from the child row.

I do not want to refresh the entire page because the records displayed are based on search criteria.

Master / parts are created using repeaters

Trying to update a record from the code behind is really fancy and still has no idea about updating the display.

Using jQuery and a web service, I assume that I can directly update the database, query what I want to display, and simply update this record. This is what makes me wonder how asp.net is just bothering me.

  ________________________________________________________________________
 |  - 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: ASP.NET related issue is not ajax related. Yes, I use jQuery to make the interfaces more dynamic, for example, show / hide the search section when it is not needed, and reset the details from the tree, but that’s all I do with it.

My concern is that if I want to check which button was pressed in this example, I have to use some tricks that are a little annoying.

If you want to use the data binding drop-down lists in the repeater, you need to use codebehind to set the selected value, it will be a pain to restore the selected data.

Next, if you want to check what data has been changed, you need to save the data in the view, view the data from all the controls in the repeater, and then compare it with the data to create the update. These are the things that bother me with asp.net.

+7
jquery web-services
source share
5 answers

You do not need to give up everything like MasterPages. You can try disabling ViewState, disabling EventValidation, and using as few ASP.NET controls as possible (basically - if some functions can be easily achieved using XHTML, write it as XHTML). You can still use ASP.NET controls where you need them.

I think you are not alone. After two years working with WebForms, I got tired of them too, and after I found out how wonderful jQuery is and how well it works with web services, I significantly changed my development model. I am moving slowly to MVC right now, because I find this the final solution, but for some other applications (small and / or target 2.0) I am just trying to use fewer server controls, get rid of ViewState, use more AJAX (web services). It is working fine. I would recommend Dave Ward Encosia - start with this article . I admit that this opened my eyes to some other ways of developing web applications using the .NET Framework. Good luck

+4
source share

When used properly, ASP.NET and JavaScript / jQuery web applications can really complement each other. I have now implemented jQuery in three different web applications and love every minute. As long as you use each component in your power, you will ultimately be satisfied with the project at the end.

You specifically mentioned that the Control identifier was causing the problem, but this was not really a big deal.

Javascript

document.getElementById("<%=this.MyObject.ClientID %>"); 

JQuery

 $("#<%=this.MyObject.ClientID %>").... 

In your parent child example, you can very easily handle what you discuss with ASP.NET and AJAX with UpdatePanels.

+5
source share

I think the main question you ask yourself is:

  Am I using the controls for what they've been designed to do? 

Working exclusively with ASP.NET in Framework 2.0, I found that I did not have to deal with the problems you are describing. ASP.NET may be freaky yes, but mostly when you use it for something other than what it was intended to be. In this case, custom roll-up controls easily fill a niche.

Edit:

Your problems sound like you are trying to implement AJAX methods, however in your question you are not mentioning using the AJAX framework . Look at this, as it can fill your niche.

+3
source share

Creating a table in JavaScript / jQuery is also not the most elegant. Therefore, I would skip the Repeater knob.

In addition, there are workarounds for the ClientId problem.

I have a lot of code on my page that looks like this:

var myTextBoxId = '<% = MyTextBox.ClientID%>';

If there are a bunch of controls, I need a client id because I will put them in an object

var myControlIds = {MyTextBoxID: '<% = MyTextBox.ClientID%>'};

Another task is to place specific CSS classes for your controls or the name / values ​​of custom attributes.

So your text box could be:

And my last trick is to use the find attribute "Ends With".

So your jquery instead

$ ("# MyTextBox") // does not work due to mangalling client id

instead: $ ("[id $ = MyTextBox]")

This searches the id attribute for all controls to find the one with the value "MyTextBox"

+1
source share

This may be a paradigm shift, but if you are looking for more bread and butter and working comfortably without managing an asp.net server, Monorail may be a good option for you. It allows you what you are looking for, being a much lighter weight, as well as MVC-based architecture. I would recommend asp.net mvc if not for your .net 2.0 limitation. Since you're limited, Monorail may just be a viable choice.

+1
source share

All Articles