views:

97

answers:

1

We have to make an ASP.NET MVC or ASP.NET application for basic ajax navigation in Customer.html of Notrhwind.mdb.

We have this 3 things:

  1. A pure HTML/Javascript form having HTML input text tags, one for each field of Customers table. We have also 2 navigation buttons: NextRecord and PrevRecord having at OnClick() event : clientGetRecord(NextOrPrev)

  2. A javascript ajax clientGetRecord function, something like this: function clientGetRecord(NextOrPrev) { var oXMLHTTP = new ActiveXObject("Microsoft.XMLHTTP"); var sURL = "ServerGetRecord.aspx?ID=" + NextOrPrev; oXMLHTTP.open( "POST", sURL, FALSE ); oXMLHTTP.send(); var sResult=oXMLHTTP.responseText; var aRecord = sResult.split(";"); document.getElementById('CustomerID').value = aRecord[0]; document.getElementById('CompanyName').value = aRecord[1]; document.getElementById('ContactName').value = aRecord[2]; document.getElementById('Adress').value = aRecord[3]; //... and so on ... };

  3. We must have something like a ServerGetRecord controler function which returns to the clientGetRecord function, a simple string containing the current record fields values separated by comma and using classic ADO database handling.

The question is : How to program and invoke the ServerGetRecord function? Can i have a VB code example of ServerGetRecord function (or ASPX, or ASHX, or something else?..) ?

Thank you very much!..

A: 

Don't have any VB smaples for you, but you can create a controller (asp.net mvc) that returns a JsonResult. You get your data from the DB and build the JsonResult object to return.

Then on your client use jQuery to call the controller and get the results as json format.

This post can help you get started: http://geekswithblogs.net/michelotti/archive/2008/06/28/mvc-json---jsonresult-and-jquery.aspx

Hope this helps