Prototype更新数据不刷新实例

Prototype ajax参数请见:Prototype.js 1.4中文使用手册PDF版下载

 default.aspx源码

ContractedBlock.gif ExpandedBlockStart.gif Code
 1<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
 2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 3<html xmlns="http://www.w3.org/1999/xhtml" >
 4<head runat="server">
 5    <title>无标题页</title>
 6    <style type="text/css">
 7ExpandedBlockStart.gifContractedBlock.gif    *{
 8
 9    margin:0;
10
11    padding:0;
12
13    font-family: verdana, "ms song", 宋体,sans-serif; 
14
15    color: #494949
16
17    font-size: 12px;
18
19    line-height: 1.5em;
20
21}

22
23   #diggs
24ExpandedBlockStart.gifContractedBlock.gif{
25    border-right: fuchsia 1px solid;
26    border-top: fuchsia 1px solid;
27    border-left: fuchsia 1px solid;
28    width: 50px;
29    border-bottom: fuchsia 1px solid;
30    height: 50px;margin-left:100px;margin-top:100px;text-align: center;
31}

32ExpandedBlockStart.gifContractedBlock.gif#digg_num_42374{border-top: fuchsia 1px solid;    width: 50px;height: 15px;}
33    </style>
34    <script language="JavaScript" type="text/javascript" src="JS/Prototype.js"></script>
35    <script language="JavaScript" type="text/javascript"> 
36   function DiggNews(nid)
37ExpandedBlockStart.gifContractedBlock.gif    {
38ExpandedSubBlockStart.gifContractedSubBlock.gif    var  options={  
39                       method:'get',  
40                       parameters:"Action=newsDiggs&nid="+nid,  
41                       onComplete:function()
42ExpandedSubBlockStart.gifContractedSubBlock.gif                        {  
43                            document.getElementById("digg_num_42374").innerHTML="已推荐";                            
44                        }
  
45                   }

46    new  Ajax.Request('Default.aspx?no-cache='+Math.random(),options);
47    }

48
49    </script>
50</head>
51<body>
52    <form id="form1" runat="server">
53    
54    <div id="diggs"><span class="diggnum" >2</span>
55    <div id="digg_num_42374" onclick="DiggNews(26)">推荐</div>
56    </div>
57    </form>
58</body>
59</html>
60

default.aspx.cs源码

ContractedBlock.gif ExpandedBlockStart.gif Code
 1using System;
 2using System.Data;
 3using System.Configuration;
 4using System.Collections;
 5using System.Web;
 6using System.Web.Security;
 7using System.Web.UI;
 8using System.Web.UI.WebControls;
 9using System.Web.UI.WebControls.WebParts;
10using System.Web.UI.HtmlControls;
11
12public partial class _Default : System.Web.UI.Page
13ExpandedBlockStart.gifContractedBlock.gif{
14    protected void Page_Load(object sender, EventArgs e)
15ExpandedSubBlockStart.gifContractedSubBlock.gif    {
16        Response.CacheControl = "no-cache";
17        string Action = Request.QueryString["Action"];
18        int nid = 0;
19        if (Request.QueryString["nid"!= null)
20ExpandedSubBlockStart.gifContractedSubBlock.gif        {
21             nid = int.Parse(Request.QueryString["nid"].ToString());
22        }

23        
24        switch (Action)
25ExpandedSubBlockStart.gifContractedSubBlock.gif        {
26         
27            case "newsDiggs":
28                getCopyRight(nid);
29                break;
30               
31           
32        }

33       }

34    protected void getCopyRight(int nid)
35ExpandedSubBlockStart.gifContractedSubBlock.gif    {
36        string strsql = "update help set orderid =orderid+1 where id ="+nid;
37        Help.SQLServerDAL.SqlHelper.ExecuteNonQuery(CommandType.Text, strsql, null);
38        Response.End();
39    }

40  
41}

42

 

转载于:https://www.cnblogs.com/lgh/archive/2008/09/28/1301440.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值