请问在asp.net中要实现windows form中Splitter控件那种功能怎么办啊? ( 积分: 50 )

  • 主题发起人 主题发起人 tangsha
  • 开始时间 开始时间
T

tangsha

Unregistered / Unconfirmed
GUEST, unregistred user!
请问在asp.net中要实现windows form中Splitter控件那种功能怎么办啊?我不想用框架哈:)
 
请问在asp.net中要实现windows form中Splitter控件那种功能怎么办啊?我不想用框架哈:)
 
其实这种效果都是JS实现的,网上找个JS的代码就可以了
 
拜托讲讲具体怎么实现嘛:),比如用Dw里面的javascript内建代码段怎么做呢?,谢谢哈
 
http://www.zahui.com/html/12/22309.htm
--------------------
HTML组件库(之一:splitter)
微软自从在浏览器大战中战胜网景后,其HTML技术逐步走向组件化,从简单的javascript到scrptlet再到behavior技术,渐趋成熟。新版本的IE内部集成了许多很有用的behavior,在微软的站点上亦有免费的behavior库可供下载。其最新的web controls更是提供了几个强大的组件(工具栏,制表(TAB),树等)。用它们来构筑web程序倍感方便。从本文开始,我将推出一系列HTML组件的实现。这次给大家的是一个水平的splitter。(作为练习,希望大家把这个组件加上垂直方向split的功能)
源码一:splitter.htc
<PUBLIC:COMPONENT>
<PUBLIC:ATTACH EVENT=&quot;oncontentready&quot;
ONEVENT=&quot;fnInit()&quot;
/>
<PUBLIC:ATTACH EVENT=&quot;onmousedown&quot;
ONEVENT=&quot;fnGrab()&quot;
/>
<public:event name=&quot;onsplit&quot;
ID=idsplit />
<SCRIPT LANGUAGE=&quot;JScript&quot;>
var giY=0;
//全局变量,记载起始y坐标。
function fnInit() //初始化代码,给元素添加一个div元素,用于拖动。
{
var oDragWindow = window.document.createElement( &quot;<div style='DISPLAY: none;
FILTER: alpha( opacity=20 );POSITION: absolute;BACKGROUND-COLOR: black;overflow:hidden;'>&quot;
);
element.dragwindow = oDragWindow;
element.insertAdjacentElement( &quot;beforeEnd&quot;
, oDragWindow );
}

function fnGrab() //当鼠标按下时,显示splitter,添加鼠标事件。
{
fnShowDragWindow();
window.document.attachEvent( &quot;onmousemove&quot;
, fnMove );
window.document.attachEvent( &quot;onscroll&quot;
, fnMove );
window.document.attachEvent( &quot;onmousemove&quot;
, fnCheckState );
window.document.attachEvent( &quot;onmouseup&quot;
, fnRelease );
window.document.attachEvent( &quot;onselectstart&quot;, fnSelect );
}
function fnCheckState()
{
if( event.button != 1 ) fnRelease();
}
function fnSelect()
{
return false;
}
function fnMove() //移动鼠标时,亦同时移动splitter。
{
if (event.button != 1)
{
fnRelease();
return;
}
element.dragwindow.style.top = event.clientY + window.document.body.scrollTop;

if (event.clientY > window.document.body.clientHeight - 10 )
{
window.scrollBy(0, 10);
}
else
if (event.clientY < 10)
{
window.scrollBy(event.clientX, -10);
}
}
function fnRelease() //当鼠标释放时,解除页面的鼠标事件,隐藏splitter,并触发onsplit事件。事件带有一个dy参数表示y轴方向的增量。
{
fnHideDragWindow()
var oEvent = createEventObject();
oEvent.dy = event.clientY-giY;
window.document.detachEvent( &quot;onmousemove&quot;
, fnMove );
window.document.detachEvent( &quot;onscroll&quot;
, fnMove );
window.document.detachEvent( &quot;onmousemove&quot;
, fnCheckState );
window.document.detachEvent( &quot;onmouseup&quot;
, fnRelease );
window.document.detachEvent( &quot;onselectstart&quot;, fnSelect );
idsplit.fire(oEvent);
}
function fnShowDragWindow()
{
var iLeft=element.offsetLeft;
var o=element;
while(o.offsetParent){o=o.offsetParent;iLeft+=o.offsetLeft;}
element.dragwindow.style.height = element.offsetHeight;
element.dragwindow.style.top = event.clientY;
element.dragwindow.style.left = iLeft;
element.dragwindow.style.width = element.offsetWidth;
element.dragwindow.zIndex = 100;
element.dragwindow.style.display = &quot;block&quot;;
giY=event.clientY;
}
function fnHideDragWindow()
{
element.dragwindow.style.display = &quot;none&quot;;
element.dragwindow.style.height = &quot;&quot;;
element.dragwindow.style.top = &quot;&quot;;
element.dragwindow.style.left = &quot;&quot;;
element.dragwindow.style.width = &quot;&quot;;
element.dragwindow.zIndex = &quot;&quot;;
}
</SCRIPT>
</PUBLIC:COMPONENT>
源码二:splitter.htm(测试页面)
<html>
<head>
<title>test splitter</title>
</head>
<body>
<div style=&quot;background:gray;height:60px;width:100%;&quot;>
</div>
<table style=&quot;width:100%;height:80%;backgroung:yellow;&quot;
cellspacing=10 cellpadding=0>
<tr>
<td rowspan=3 style=&quot;width:100px;background:green;&quot;>asd</td>
<td style=&quot;height:200px;background:blue;&quot;
id=box>asd</td>
</tr>
<tr>
<td style=&quot;background:black;height:5px;cursor:n-resize;behavior:url(splitter.htc)&quot;
onsplit=&quot;box.style.pixelHeight+=event.dy;window.status=(event.dy);&quot;></td>
</tr>
<tr>
<td>asd</td>
</tr>
</table>
</body>
</html>
 
不好意思哈,我是个菜鸟,请问htc文件怎么把他安装进.net呢?就是好像delphi中安装控件一样,我该怎样把他加进来然后在我的页面里调用这个组件阿?
 
[blue]<td style=&quot;background:black;height:5px;cursor:n-resize;behavior:url(splitter.htc)&quot;
[/blue]
楼主,你好,我的回复里面是两个文件,注意后面那个文件的内容里面包括一句话,那句话就是连接htc的
 
多谢哈,我现在已经解决了,不过是用的Javascript,还是很感谢大家
 
后退
顶部