0

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?..) ?

til
  • 195
  • 1
  • 5
  • Here is a non jquery example that doesn't use `ActiveXObject` (which I'm suprised even works) https://www.w3schools.com/xml/tryit.asp?filename=tryajax_first it's referenced from here, which has plenty of other examples. https://stackoverflow.com/questions/8567114/how-to-make-an-ajax-call-without-jquery. In ASP.Net MVC, ServerGetRecord is your controller URL that returns what you want. – Nick.McDermaid Sep 04 '17 at 08:53

1 Answers1

0

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

  • Thank you very much!The get started sample don't work. You must replace 'listitem' by 'SelectListItem' in code and web.config by the one generated by ASP.NET MVC 1.0 However I am still searching for a basic solution using XMLHTTPRequest and returning a simple string value (without jQuery & JSON). –  Apr 02 '09 at 18:05