Best practices for developing simple ASP.NET sites (built in controls or JQuery + scripts)
- by Nix
I was recently reviewing some code written by two different contractors, both were basic ASP.NET management sites. The sites allowed the user to view and edit data. Pretty much simple CRUD gateways.
One group did their best to use built in ASP + AJAX Toolkit controls and did their best to use as many built in controls as possible. I found the code much easier to read and maintain.
The other used jQuery and the code is heavily marked up with script blocks which are then used to build pages from javascript files.
Which one is more common? The one that basically leveraged embedded HTML markup in scripts controled by javascript files screams readability and maintenance issues? Is this just the way of doing asp dev with jQuery?
Assuming the second example happens a lot, are there tools that help facilitate jQuery development with visual studio? Do you think they generated the html somewhere else and just copied it in?
Example Script block:
<script id="HRPanel" type="text/html">
<table cellpadding='0' cellspacing='0' class="atable"><thead class="mHeader"><tr><th>Name</th><th>Description</th><th>Other</th></thead><tbody>
<# for(var i=0; i < hrRows.length; i++) {
var r = HRRows[i]; #>
<tr><td><#=r.Name#></td><td><#=r.Description#></td><td class="taRight"><#=r.Other#></td></tr>
<#}#>
</tbody><tfoot><th></th><th></th><th></th></tfoot></table>
</script>
Then in a separate location (js file) you would see something like this.
$("#HRPanel").html($("#HRPanel").parseTemplate({ HRRows: response.something.bah.bah }));