Example
Source
Run as server control
This example shows how
DbNetEdit
may be used with its own encapsulated navigation and toolbar components to generate a fully-functional data maintenance application in just a few lines of code.
Categories
Id
Name
Description
Include the Javascript library file
<script src="../dbnetedit.js"></script>
Client-side script
window.onload = initEdit ////////////////////////////////////////////////////////////////////////////////////////////// function initEdit() ////////////////////////////////////////////////////////////////////////////////////////////// { var categoryForm = new DbNetEdit( "dbnetedit1" ); with (categoryForm) { connectionString = "samples" tableName = "categories" primaryKeyName = "categoryid" browseColumns = ["categoryname"] browseTitles = ["Category"] onEditError = customEditErrorMessage onDeleteError = customEditErrorMessage initialise() } } ////////////////////////////////////////////////////////////////////////////////////////////// function customEditErrorMessage(form) ////////////////////////////////////////////////////////////////////////////////////////////// { var serverMessage = ['operation must use an updateable query', 'database or object is read-only', 'could not delete from specified tables'] for (var i = 0; i<serverMessage.length; i++) { if (form.msg.toLowerCase().indexOf(serverMessage[i])) { var msg = 'Database table is read-only, this is usually related to the\n' + 'permissions on the file nwind.mdb in the samples folder.\n\n' + 'To correct this problem:\n\n' + '\t1. Select the file using Windows Explorer\n' + '\t2. Right-click on the file and select Properties\n' + '\t3. Select the Security tab\n' + '\t4. Assign "Full Control" to "Everyone" and click "OK"\n\n' + 'If the problem persists then contact support@dbnetedit.com' alert(msg) form.msg = 'Database customer.mdb is read-only' break } } }
HTML
<div id=dbnetedit1 style='width:33%'> <fieldset> <legend>Categories</legend> <table cellspacing=5> <tr> <td colspan=2> <table> <tr> <td id=editNavigation> </td> <td id=toolbar> </td> </tr> </table> </td> </tr> <tr> <td>Id</td> <td><input id=categoryid class=dbnetedit></td> </tr> <tr> <td>Name</td> <td><input id=categoryname class=dbnetedit></td> </tr> <tr> <td>Description</td> <td><textarea id=description class=dbnetedit></textarea></td> </tr> <tr> <td id=navigatorStatus colspan=2> </td> </tr> <tr> <td colspan=2 id=messageLine> </td> </tr> </table> </fieldset> </div>