<%@ Register TagPrefix="iewc" Namespace="Microsoft.Web.UI.WebControls" Assembly="Microsoft.Web.UI.WebControls" %>
<%@ Control Language="c#" AutoEventWireup="false" Codebehind="SelUnit.ascx.cs" Inherits="DXK.Web.component.SelUnit" TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>
<script type="text/javascript">
//Sel_Text.onclick = function()
function clickSel(obj)
{
if(divTree.style.display == 'none')
{
divTree.style.display = '';
divTree.style.top = findOffsetTop(obj) + obj.offsetHeight;
divTree.style.left = findOffsetLeft(obj);
}
else
{
divTree.style.display = 'none';
}
}
document.onclick = function()
{
var the_obj = event.srcElement;
if ((the_obj.id.indexOf('_Sel_Text') == -1) && (get_ElementById(the_obj, 'divTree') == null))
{
if(divTree.style.display == '')
divTree.style.display = 'none';
}
}
function get_ElementById(the_ele,the_id)
{
the_id = the_id.toLowerCase();
if(the_ele.id.toLowerCase()==the_id)return the_ele;
while(the_ele=the_ele.offsetParent){
if(the_ele.id.toLowerCase()==the_id)return the_ele;
}
return(null);
}
function dodblclick(objTV, UCTag)
{
if(objTV.getTreeNode(objTV.clickedNodeIndex)!=undefined)
{
document.getElementById(UCTag+'_Sel_Text').value = objTV.getTreeNode(objTV.clickedNodeIndex).getAttribute("Text");
document.getElementById(UCTag+'_Sel_Value').value = objTV.getTreeNode(objTV.clickedNodeIndex).getAttribute("NodeData");
divTree.style.display = 'none';
}
}
function findOffsetTop(o)
{
var t = 0;
if (o.offsetParent)
{
while (o.offsetParent)
{
t += o.offsetTop;
o = o.offsetParent;
}
}
return t;
}
function findOffsetLeft(o)
{
var t = 0;
if (o.offsetParent)
{
while (o.offsetParent)
{
t += o.offsetLeft;
o = o.offsetParent;
}
}
return t;
}
</script>
<input id="Sel_Text" style="BACKGROUND-POSITION-X: right; BACKGROUND-IMAGE: url(../images/seltip.jpg); WIDTH: 150px; CURSOR: pointer; BACKGROUND-REPEAT: no-repeat"
readOnly type="text" runat="server"> <INPUT id="Sel_Value" type="hidden" runat="server">
<DIV id="divTree" style="BORDER-RIGHT: black 1px groove; BORDER-TOP: black 1px groove; DISPLAY: none; OVERFLOW: auto; BORDER-LEFT: black 1px groove; WIDTH: 240px; BORDER-BOTTOM: black 1px groove; POSITION: absolute; HEIGHT: 350px"><iewc:treeview id="tvUnitList" runat="server" BorderWidth="0px" BorderStyle="None"
Indent="20" SelectExpands="True" ShowToolTip="False"></iewc:treeview></DIV>
<%@ Control Language="c#" AutoEventWireup="false" Codebehind="SelUnit.ascx.cs" Inherits="DXK.Web.component.SelUnit" TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>
<script type="text/javascript">
//Sel_Text.onclick = function()
function clickSel(obj)
{
if(divTree.style.display == 'none')
{
divTree.style.display = '';
divTree.style.top = findOffsetTop(obj) + obj.offsetHeight;
divTree.style.left = findOffsetLeft(obj);
}
else
{
divTree.style.display = 'none';
}
}
document.onclick = function()
{
var the_obj = event.srcElement;
if ((the_obj.id.indexOf('_Sel_Text') == -1) && (get_ElementById(the_obj, 'divTree') == null))
{
if(divTree.style.display == '')
divTree.style.display = 'none';
}
}
function get_ElementById(the_ele,the_id)
{
the_id = the_id.toLowerCase();
if(the_ele.id.toLowerCase()==the_id)return the_ele;
while(the_ele=the_ele.offsetParent){
if(the_ele.id.toLowerCase()==the_id)return the_ele;
}
return(null);
}
function dodblclick(objTV, UCTag)
{
if(objTV.getTreeNode(objTV.clickedNodeIndex)!=undefined)
{
document.getElementById(UCTag+'_Sel_Text').value = objTV.getTreeNode(objTV.clickedNodeIndex).getAttribute("Text");
document.getElementById(UCTag+'_Sel_Value').value = objTV.getTreeNode(objTV.clickedNodeIndex).getAttribute("NodeData");
divTree.style.display = 'none';
}
}
function findOffsetTop(o)
{
var t = 0;
if (o.offsetParent)
{
while (o.offsetParent)
{
t += o.offsetTop;
o = o.offsetParent;
}
}
return t;
}
function findOffsetLeft(o)
{
var t = 0;
if (o.offsetParent)
{
while (o.offsetParent)
{
t += o.offsetLeft;
o = o.offsetParent;
}
}
return t;
}
</script>
<input id="Sel_Text" style="BACKGROUND-POSITION-X: right; BACKGROUND-IMAGE: url(../images/seltip.jpg); WIDTH: 150px; CURSOR: pointer; BACKGROUND-REPEAT: no-repeat"
readOnly type="text" runat="server"> <INPUT id="Sel_Value" type="hidden" runat="server">
<DIV id="divTree" style="BORDER-RIGHT: black 1px groove; BORDER-TOP: black 1px groove; DISPLAY: none; OVERFLOW: auto; BORDER-LEFT: black 1px groove; WIDTH: 240px; BORDER-BOTTOM: black 1px groove; POSITION: absolute; HEIGHT: 350px"><iewc:treeview id="tvUnitList" runat="server" BorderWidth="0px" BorderStyle="None"
Indent="20" SelectExpands="True" ShowToolTip="False"></iewc:treeview></DIV>
.cs后台代码