我想构建一个简单的表单,可用于创建记录(C=Create)、从数据库读取记录数据(R=Read)、从数据库更新记录(U=Update)并删除从数据库中记录(D=删除)。我不想在 Ext JS 示例中使用 PHP。我更喜欢在 ASP.NET 中使用 WCF 或 HTTP 处理程序(*.ashx 文件)。有人可以帮我写代码吗?我不需要有关数据库访问的详细信息。我只是在努力获取客户端代码方面,以及我应该在服务器代码方法上使用哪些参数和返回类型。
我想模仿这种架构,但使用 Ext JS 客户端代码: http: //www.codeproject.com/Articles/283976/CRUD-Create-Read-Update-Delete
如果您选择 WCF,我使用的是 REST,而不是 SOAP:
http ://www.dotnetcurry.com/ShowArticle.aspx?ID=728
我在 Amazon.com 上订购了用于 Web 应用程序的 Ext JS 4 Cookbook,但它已经缺货 2 个月了。
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>...</title>
<!-- ExtJS -->
<link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" />
<script type="text/javascript" src="../../ext-all.js"></script>
<!-- Shared -->
<link rel="stylesheet" type="text/css" href="../shared/example.css" />
<!-- GC -->
<!-- Example -->
<script type="text/javascript" src="dynamic.js"></script>
</head>
<body>
<h1>CRUD example with Ext JS 4 dynamic form</h1>
</body>
</html>
JavaScript
Ext.require([
//'Ext.form.*',
//'Ext.layout.container.Column',
//'Ext.tab.Panel'
'*'
]);
Ext.onReady(function () {
Ext.QuickTips.init();
var bd = Ext.getBody();
/*
* ================ Simple form =======================
*/
bd.createChild({ tag: 'h2', html: 'Form 1 - Very Simple' });
var required = '<span style="color:red;font-weight:bold" data-qtip="Required">*</span>';
var simple = Ext.widget({
xtype: 'form',
layout: 'form',
collapsible: true,
id: 'simpleForm',
url: 'save-form.php',
frame: true,
title: 'Simple Form',
bodyPadding: '5 5 0',
width: 350,
fieldDefaults: {
msgTarget: 'side',
labelWidth: 75
},
defaultType: 'textfield',
items: [{
fieldLabel: 'First Name',
afterLabelTextTpl: required,
name: 'first',
allowBlank: false
}, {
fieldLabel: 'Last Name',
afterLabelTextTpl: required,
name: 'last'
}, {
fieldLabel: 'Company',
name: 'company'
}, {
fieldLabel: 'Email',
afterLabelTextTpl: required,
name: 'email',
vtype: 'email'
}, {
fieldLabel: 'DOB',
name: 'dob',
xtype: 'datefield'
}, {
fieldLabel: 'Age',
name: 'age',
xtype: 'numberfield',
minValue: 0,
maxValue: 100
}, {
xtype: 'timefield',
fieldLabel: 'Time',
name: 'time',
minValue: '8:00am',
maxValue: '6:00pm'
}],
buttons: [{
text: 'Save'
}, {
text: 'Cancel'
}]
});
simple.render(document.body);
});