<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="MyTest.WebForm1" %><%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI" TagPrefix="asp" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<script type="text/javascript" language="javascript">
var move_obj_x0=0,move_obj_y0=0,move_obj_x1=0,move_obj_y1=0;//(x0,y0)为开始拖动时鼠标的位置(x1,y1)为开始拖动时对象的位置
var obj_moveable=false; //开始拖动;
function startDrag(obj,id)
{
if(event.button==1)
{
obj.setCapture();
win=document.getElementById(id)
move_obj_x0 = event.clientX;
move_obj_y0 = event.clientY;
move_obj_x1 = parseInt(win.style.left);
move_obj_y1 = parseInt(win.style.top);
obj_moveable = true;
}
}
//拖动;
function drag(id)
{
if(obj_moveable)
{
win=document.getElementById(id)
win.style.left = (move_obj_x1 + event.clientX - move_obj_x0>0)?move_obj_x1 + event.clientX - move_obj_x0:0;
win.style.top = (move_obj_y1 + event.clientY - move_obj_y0>0)?move_obj_y1 + event.clientY - move_obj_y0:0;
}
}
//停止拖动;
function stopDrag(obj,id)
{
if(obj_moveable)
{
obj.releaseCapture();
obj_moveable = false;
}
} </script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<table cellSpacing="0" cellPadding="0" width="100%" border="0">
<tr>
<td height="25" width="30%" align="right">
TestID
</td>
<td height="25" width="*">
<asp:TextBox id="txtTestID" runat="server" Width="200px"></asp:TextBox>
</td></tr>
<tr>
<td height="25" width="30%" align="right">
TestName
</td>
<td height="25" width="*">
<asp:TextBox id="txtTestName" runat="server" Width="200px"></asp:TextBox>
</td></tr>
<tr>
<td height="25" width="30%" align="right">
TestDate
</td>
<td height="25" width="*">
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
<asp:Button ID="Button2" runat="server" Text="Button" OnClick="Button2_Click" /></td></tr>
</table>
</div> <asp:UpdatePanel ID="UpdatePanel1" runat="server" Visible="False">
<ContentTemplate>
<div id="menu3" style=" border:solid 1px;width:65%; z-index:5; position:absolute; left: 180px; top: 147px;" runat="server" onmousedown="startDrag(this,'menu3')" onmousemove="drag('menu3')" onmouseup="stopDrag(this,'menu3')">
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>
Namespace="System.Web.UI" TagPrefix="asp" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<script type="text/javascript" language="javascript">
var move_obj_x0=0,move_obj_y0=0,move_obj_x1=0,move_obj_y1=0;//(x0,y0)为开始拖动时鼠标的位置(x1,y1)为开始拖动时对象的位置
var obj_moveable=false; //开始拖动;
function startDrag(obj,id)
{
if(event.button==1)
{
obj.setCapture();
win=document.getElementById(id)
move_obj_x0 = event.clientX;
move_obj_y0 = event.clientY;
move_obj_x1 = parseInt(win.style.left);
move_obj_y1 = parseInt(win.style.top);
obj_moveable = true;
}
}
//拖动;
function drag(id)
{
if(obj_moveable)
{
win=document.getElementById(id)
win.style.left = (move_obj_x1 + event.clientX - move_obj_x0>0)?move_obj_x1 + event.clientX - move_obj_x0:0;
win.style.top = (move_obj_y1 + event.clientY - move_obj_y0>0)?move_obj_y1 + event.clientY - move_obj_y0:0;
}
}
//停止拖动;
function stopDrag(obj,id)
{
if(obj_moveable)
{
obj.releaseCapture();
obj_moveable = false;
}
} </script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<table cellSpacing="0" cellPadding="0" width="100%" border="0">
<tr>
<td height="25" width="30%" align="right">
TestID
</td>
<td height="25" width="*">
<asp:TextBox id="txtTestID" runat="server" Width="200px"></asp:TextBox>
</td></tr>
<tr>
<td height="25" width="30%" align="right">
TestName
</td>
<td height="25" width="*">
<asp:TextBox id="txtTestName" runat="server" Width="200px"></asp:TextBox>
</td></tr>
<tr>
<td height="25" width="30%" align="right">
TestDate
</td>
<td height="25" width="*">
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
<asp:Button ID="Button2" runat="server" Text="Button" OnClick="Button2_Click" /></td></tr>
</table>
</div> <asp:UpdatePanel ID="UpdatePanel1" runat="server" Visible="False">
<ContentTemplate>
<div id="menu3" style=" border:solid 1px;width:65%; z-index:5; position:absolute; left: 180px; top: 147px;" runat="server" onmousedown="startDrag(this,'menu3')" onmousemove="drag('menu3')" onmouseup="stopDrag(this,'menu3')">
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货