如何使用数据绑定控件实现不换页提交数据?

时间:2010-05-16 15:17:00 

如何使用数据绑定控件实现不换页提交数据?

Chunfeng.html


' 提交页面
< html>
< head> 
< title> 本页提交 - aspxhome.com< /title>
< /head> 
< !--DataSource is Data Binding control--> 
< object classid="clsid:333C7BC4-460F-11D0-BC04-0080C7055A83" id="DataSource" VIEWASTEXT>
< param NAME="UseHeader" VALUE="True"> 
< param NAME="FieldDelim" VALUE=","> 
< param NAME="DataURL" VALUE="ProcessData.asp?ID=0"> 
< /object> 
< script for=DataSource event=ondatasetcomplete>
Name.value = ""; 
Age.value = ""; 
Age.disabled = true; 
outputButton.disabled = true;
< /script> 
< script>
var rowindex = 0; 
function clickTR()
{
var srcElement = event.srcElement;
while(srcElement.tagName != "TR") 
 { 
  srcElement = srcElement.parentElement;
  }
rowindex = srcElement.rowIndex; 
Name.value = srcElement.cells(0).innerText;
Age.value = srcElement.cells(1).innerText;
Age.disabled = false; 
outputButton.disabled = false;

function submitData() 
{
var rs = DataSource.recordset;
rs.AbsolutePosition = rowindex;
if(rs("Name").value == Name.value && rs("Age").value == Age.value)
 {
  alert("Data no change"); return; 
 } 
var szReturn;
szReturn = "ProcessData.asp?Name=" + Name.value + "&ID=" + rs("ID").value + "&Age=" + Age.value;
DataSource.DataURL = szReturn; 
DataSource.reset(); 
outputButton.disabled = true;

< /script>
< body> 
< table datasrc=#DataSource CELLPADDING="0" CELLSPACING="0" BORDER="1" WIDTH="100%">
< thead> 
< th>姓名< /th> 
< th>年龄< /th> 
< /thead>
< tr style="Cursor:Hand" onclick="clickTR();" onmouseover="this.style.backgroundColor='silver';" 
onmouseout="this.style.backgroundColor='white';"> 
< td><span datafld=Name>< /td>
< td><span datafld=Age>< /td> 
< /tr>
< /table>
< hr> 
< table width=100%> 
< tr> 
  < td width=30%>姓名</td>
  < td width=30%>年龄</td>
  < td width=100%> </td>
< /tr> 
< tr> 
< td width=30%>< input style="width:100%" id=Name disabled>< /td> 
< td width=30%>< input style="width:100%" id=Age disabled>< /td> 
< td width=100%>< input type=button value="现在提交" id= outputButton disabled on click="submitData( );">< /td>
< /tr> 
< /table> 
< /body> 
< /html> 

ProcessData.asp

' 数据处理
< %@ Language=VBScript %> 
< % 
dim id
dim enter 
enter = chr(10) 
id = request.querystring("ID") 
set d = server.createobject("scripting.filesystemobject")
if id < > 0 then
  set read = d.opentextfile("c:\inetpub\wwwroot\test\Data.csv ")
  set write = d.Createtextfile("c:\inetpub\wwwroot\test\ Data1.csv ") 
  dim index 
  dim string 
  id = id + 1 
  index = 1 
  while not read.AtEndOfStream
     if index = id then
     dim name 
     dim age 
     name = request.querystring("name") 
     age = request.querystring("age")
     string = id - 1 & "," & name & "," & age 
     write.WriteLine(string)
     read.ReadLine 
  else 
     write.writeLine(read.ReadLine)
  end if 
  index = index + 1
  wend 
  read.Close 
  write.Close
  d.CopyFile "c:\inetpub\wwwroot\test\Data1.csv",
  "c:\inetpub\wwwroot\test\ Data.csv " 
  d.DeleteFile "c:\inetpub\wwwroot\test\ Data1.csv " 
end if
set file = d.opentextfile("c:\inetpub\wwwroot\test\ Data.csv ")
while not file.AtEndOfStream
Response.write (file.ReadLine) 
Response.write enter wend file.Close %> 

Data.csv
' 数据文件
ID:int,Name:string,Age:int
1,Victor, 23
2,Bill,31
3,kenny,31
4,hunter,24

标签:绑定,控件,提交数据
0
投稿

猜你喜欢

  • SQL Server无日志恢复数据库(2种方法)

    2024-01-17 03:40:56
  • Pytorch.nn.conv2d 过程验证方式(单,多通道卷积过程)

    2021-12-24 13:28:27
  • python爬虫 正则表达式解析

    2022-07-16 18:24:01
  • python logging多进程多线程输出到同一个日志文件的实战案例

    2021-01-08 16:25:17
  • Django 权限认证(根据不同的用户,设置不同的显示和访问权限)

    2023-09-18 04:07:30
  • pymysql 插入数据 转义处理方式

    2024-01-23 08:43:29
  • Python实现网络聊天室的示例代码(支持多人聊天与私聊)

    2022-11-21 15:17:23
  • python爬虫数据保存到mongoDB的实例方法

    2021-10-10 09:52:24
  • keras处理欠拟合和过拟合的实例讲解

    2022-06-23 05:14:38
  • python爬虫scrapy基于CrawlSpider类的全站数据爬取示例解析

    2022-12-17 22:26:30
  • Python selenium爬取微信公众号文章代码详解

    2023-12-10 19:43:18
  • 详解Python中使用base64模块来处理base64编码的方法

    2022-01-12 01:27:19
  • sql获取分组排序后数据的脚本

    2024-01-20 09:07:58
  • 在python中bool函数的取值方法

    2021-10-06 00:47:37
  • Python实现抓取页面上链接的简单爬虫分享

    2021-03-28 23:03:13
  • python 3.10上如何安装pyqt5

    2022-04-09 23:59:53
  • Oracle 数据显示 横表转纵表

    2024-01-22 23:35:05
  • Python对图片进行resize、裁剪、旋转、翻转问题

    2023-03-01 11:07:05
  • Mootools常用方法扩展(二)

    2009-01-11 18:22:00
  • python 多线程实现检测服务器在线情况

    2021-12-11 15:15:58
  • asp之家 网络编程 m.aspxhome.com