概述
aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication2._Default" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" 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>Untitled Page</title>
</head>
<body>
<script type="text/javascript">
function pageLoad() {
var queryDetail = $get("<%=Test.ClientID%>");
if (queryDetail != null) {
// call the savePanelPosition when the panel is moved
$find('Drag').add_move(savePanelPosition);
var elem = $get("<%=HiddenField1.ClientID%>");
if (elem.value != "0") {
var temp = new Array();
temp = elem.value.split(';');
// set the position of the panel manually with the retrieve value
$find('<%=DragPanelExtender1.BehaviorID%>').set_location(new Sys.UI.Point(parseInt(temp[0]), parseInt(temp[1])));
}
}
}
function savePanelPosition() {
var elem = $find('Drag').get_element();
var loc = $common.getLocation(elem);
var elem1 = $get("<%=HiddenField1.ClientID%>");
// store the value in the hidden field
elem1.value = loc.x + ';' + loc.y;
}
</script>
<form id="form1" runat="server">
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div style="width: 100%; height: 400px; background-color: Green">
<asp:Panel ID="Test" runat="server" Width="20%" Height="20px" BackColor="Blue" Visible="false">
<asp:Button ID="btn_close" runat="server" Text="关闭" οnclick="btn_close_Click" />
..............................
</asp:Panel>
<asp:DragPanelExtender ID="DragPanelExtender1" runat="server" TargetControlID="Test" BehaviorID="Drag">
</asp:DragPanelExtender>
<asp:Button ID="Button1" runat="server" Text="Button" />
<asp:Button ID="btn_show" runat="server" Text="弹出" TabIndex="15" Width="78px" οnclick="btn_show_Click" />
<asp:HiddenField ID="HiddenField1" runat="server" Value="0"/>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>
CS
CS
protected void btn_show_Click(object sender, EventArgs e)
{
Test.Visible = true;
}
protected void btn_close_Click(object sender, EventArgs e)
{
Test.Visible = false;
}
最后
以上就是朴实白开水为你收集整理的弹出一个Panel(DIV),实例代码的全部内容,希望文章能够帮你解决弹出一个Panel(DIV),实例代码所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复