AJAX简单实现新闻拖放系统

javascript代码: href="css/pub.css" type="text/css" rel="stylesheet" /> <script type="text/javascript"> function init() { //左边的新闻 var NewsIdss=NewsDrop.NewsID("Left").value; var NewsIds=NewsIdss.split("|"); for(var i=0;i divLeft.right&&tX<=divCenter.right) { document.getElementById("Center").appendChild(aoo); } else if(tX>divCenter.right) { document.getElementById("Right").appendChild(aoo); } } function dragEnd() { //debugger if(!draged)return; draged=false; mm=ff(150,15); } function getInfo(o) {//取得坐标 var to=new Object(); to.left=to.right=to.top=to.bottom=0; var twidth=o.offsetWidth; var theight=o.offsetHeight; while(o!=document.body) { to.left+=o.offsetLeft; to.top+=o.offsetTop; o=o.parentElement; } to.right=to.left+twidth; to.bottom=to.top+theight; return to; } function ff(aa,ab){//从GOOGLE网站来,用于恢复位置 var ac=parseInt(getInfo(tdiv).left); var ad=parseInt(getInfo(tdiv).top); var ae=(ac-getInfo(aoo).left)/ab; var af=(ad-getInfo(aoo).top)/ab; return setInterval(function(){if(ab<1) { clearInterval(mm); tdiv.removeNode(true); aoo=null; return } ab--; ac-=ae; ad-=af; tdiv.style.left=parseInt(ac)+"px"; tdiv.style.top=parseInt(ad)+"px" } ,aa/ab) } </script>
c#代码: using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using Ajax; public partial class NewsDrop : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Ajax.Utility.RegisterTypeForAjax(typeof(NewsDrop)); } [Ajax.AjaxMethod()] public string NewsID(string location) { DB dv = new DB(); return dv.getNewsID(location); } [Ajax.AjaxMethod()] public string NewsTitle(int id) { DB dv = new DB(); return dv.getNewsTitle(id); } [Ajax.AjaxMethod()] public string NewsContent(int Id) { DB dv = new DB(); return dv.getNewsContent(Id); } }
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值