您的位置:首页 > 运维架构

封装一个Drop and Drag面板控件,供大家分享

2009-10-04 13:39 555 查看
一直想封装一个像Google个性主页那样的可拖动布局管理器,供管理后台作为默认首页使用。
在网上搜了一下,找到此篇文章对google个性主页的拖拽效果的js的完整注释。在此先向原作者致敬,没有这篇文章,我是没法封装此控件的:)
不用多说,先附上效果图:
var Util = new Object();
2Util.getUserAgent = navigator.userAgent;
3Util.isGecko = Util.getUserAgent.indexOf("Gecko") != -1;
4Util.isOpera = Util.getUserAgent.indexOf("Opera") != -1;
5
14
20
33
40ghostElement = null;
41
51
69
225
243using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.IO;
6using System.Web;
7using System.ComponentModel;
8using System.Web.UI;
9using System.Web.UI.Design;
10using System.Web.UI.WebControls;
11
12[assembly: WebResource("pqmagic.Common.UI.Resources.DragDrop.js", "text/javascript")]
13namespace pqmagic.Common.UI
14 容器内部可拖动的面板DragDropPanel.cs

Code
using System;
using System.Reflection;
using System.Security.Permissions;
using System.Web;
using System.Drawing.Design;
using System.Web.UI;

namespace pqmagic.Common.UI
{
[AspNetHostingPermission(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal), AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class DragDropPanelCollection : ControlCollection
{
public DragDropPanelCollection(Control owner):base(owner)
{
}

public override void Add(Control child)
{
if (!(child is DragDropPanel))
{
throw new ArgumentException("该集合只能添加DragDropPanel类型的控件");
}
base.Add(child);
}

public override void AddAt(int index, Control child)
{
if (!(child is DragDropPanel))
{
throw new ArgumentException("该集合只能添加DragDropPanel类型的控件");
}
base.AddAt(index, child);
}

public new DragDropPanel this[int index]
{
get
{
return (DragDropPanel)base[index];
}
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: