I know jQuery is currently everybody's darling hammer (truth be told, I'm enamored with it, too), but I'm wondering if dynamically generating html might be more elegantly, or more easily, done using Razor/C#. For example, to update a page, consider this Razor pseudocode:
@{
var divContent = functions.getDivContent("Platypus");
if(IsPost)
{
divContent = functions.getDivContent(request[mammalName]);
}
else
{
;//anything?
}
}
//The getDivContent() function in functions (not shown) returns dynamically generated html
HTML pseudocode:
<body>
<form method="POST" action="" >
<input type="Select" name="mammalName" ... />
</form>
<div>@divContent</div>
</body>
jQuery pseudocode:
$('mammalName').selectionChanged() {
$('form').submit();
});
Doing all of this in a jQuery function, such as using json data and calling .getJson(), would obviate the need for a complete page refresh, but in either case the server has to be queried for data, so I don't know if that's really such an advantage, especially in the case (mine) where the part of the page being refreshed is the lion's share of the page.
Is there a flaw in my thinking/design? Is there a compelling reason to choose jQuery over Razor here?