阿德,快看啊!!关于接口,我不会!!

来源:互联网 发布:惊艳的句子知乎 编辑:程序博客网 时间:2024/05/02 02:48

主要是关于ASP.NET。

下面代码存成OnMouseOver.ascx,也就是说,这是前台代码,后台代码的名字是OnMouseOver.ascx.cs。这是一个用户自定义控件先看代码!!

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="OnMouseOver.ascx.cs" Inherits="OnMouseOver" %>

<script language="JavaScript" type="text/JavaScript" >
//下拉菜单相关代码
 var h;
 var w;
 var l;
 var t;
 var topMar = 1;
 var leftMar = -2;
 var space = 1;
 var isvisible;
 var MENU_SHADOW_COLOR='steelblue';//定义下拉菜单阴影色
 var global = window.document
 global.fo_currentMenu = null
 global.fo_shadows = new Array

function HideMenu()
{                                                                                                                                                                         
 var mX;
 var mY;
 var vDiv;
 var mDiv;
 if (isvisible == true)
{
  vDiv = document.all("menuDiv");
  mX = window.event.clientX + document.body.scrollLeft;
  mY = window.event.clientY + document.body.scrollTop;
  if ((mX < parseInt(vDiv.style.left)) || (mX > parseInt(vDiv.style.left)+vDiv.offsetWidth) || (mY < parseInt(vDiv.style.top)-h) || (mY > parseInt(vDiv.style.top)+vDiv.offsetHeight))
  {
   vDiv.style.visibility = "hidden";
   isvisible = false;
  }
}
}

function ShowMenu(vMnuCode,tWidth) {
 vSrc = window.event.srcElement;
 vMnuCode = "<table id='submenu' cellspacing=1 cellpadding=3 style='width:"+tWidth+"' class=menu onmouseout='HideMenu()'><tr height=23><td nowrap align=left class=MenuBody>" + vMnuCode + "</td></tr></table>";

 h = vSrc.offsetHeight;
 w = vSrc.offsetWidth;
 l = vSrc.offsetLeft + leftMar+4;
 t = vSrc.offsetTop + topMar + h + space-2;
 vParent = vSrc.offsetParent;
 while (vParent.tagName.toUpperCase() != "BODY")
 {
  l += vParent.offsetLeft;
  t += vParent.offsetTop;
  vParent = vParent.offsetParent;
 }

 menuDiv.innerHTML = vMnuCode;
 menuDiv.style.top = t;
 menuDiv.style.left = l;
 menuDiv.style.visibility = "visible";0
 isvisible = true;
    makeRectangularDropShadow(submenu, MENU_SHADOW_COLOR, 4)
}

function makeRectangularDropShadow(el, color, size)
{
 var i;
 for (i=size; i>0; i--)
 {
  var rect = document.createElement('div');
  var rs = rect.style
  rs.position = 'absolute';
  rs.left = (el.style.posLeft + i) + 'px';
  rs.top = (el.style.posTop + i) + 'px';
  rs.width = el.offsetWidth + 'px';
  rs.height = el.offsetHeight + 'px';
  rs.zIndex = el.style.zIndex - i;
  rs.backgroundColor = color;
  var opacity = 1 - i / (i + 1);
  rs.filter = 'alpha(opacity=' + (100 * opacity) + ')';
  el.insertAdjacentElement('afterEnd', rect);
  global.fo_shadows[global.fo_shadows.length] = rect;
 }
}
</script>

<script language="JavaScript" type="text/JavaScript" >
//菜单列表
var menu1="<a style=font-size:9pt;line-height:14pt; href=' '>一</a><br><a style=font-size:9pt;line-height:14pt; href=' '>二</a><br>"
var menu2="<a style=font-size:9pt;line-height:14pt; href=' '>一</a><br><a style=font-size:9pt;line-height:14pt; href=' '>二</a><br>"
var menu3="<a style=font-size:9pt;line-height:14pt; href=' '>一</a><br><a style=font-size:9pt;line-height:14pt; href=' '>二</a><br>"
var menu4="<a style=font-size:9pt;line-height:14pt; href=' '>一</a><br><a style=font-size:9pt;line-height:14pt; href=' '>二</a><br>"
var menu5="<a style=font-size:9pt;line-height:14pt; href=' '>一</a><br><a style=font-size:9pt;line-height:14pt; href=' '>二</a><br>"
var menu6="<a style=font-size:9pt;line-height:14pt; href=' '>一</a><br><a style=font-size:9pt;line-height:14pt; href=' '>二</a><br>"
var menu7="<a style=font-size:9pt;line-height:14pt; href=' '>一</a><br><a style=font-size:9pt;line-height:14pt; href=' '>二</a><br>"
var menu8="<a style=font-size:9pt;line-height:14pt; href=' '>一</a><br><a style=font-size:9pt;line-height:14pt; href=' '>二</a><br>"
</script>
<meta content="MSHTML 6.00.2900.2802" name="GENERATOR">
<div id=menuDiv style="Z-INDEX: 1000; VISIBILITY: hidden;  POSITION: absolute;  BACKGROUND-COLOR: #9966cc"></div>
<body onmousemove="HideMenu()" leftMargin=0 topMargin=0>
<table ><!--DWLayoutTable-->
   <tr style ="width :100%" align ="center" >
    <td><a onmouseover="ShowMenu(menu1,100)" href="DocList.aspx">文档</a></td>
    <td><a onmouseover="ShowMenu(menu2,100)" href="DocList.aspx">文档</a></td>
    <td><a onmouseover="ShowMenu(menu3,100)" href="DocList.aspx">文档</a></td>
    <td><a onmouseover="ShowMenu(menu4,100)" href="DocList.aspx">文档</a></td>
    <td><a onmouseover="ShowMenu(menu5,100)" href="DocList.aspx">文档</a></td>
    <td><a onmouseover="ShowMenu(menu6,100)" href="DocList.aspx">文档</a></td>
    <td><a onmouseover="ShowMenu(menu7,100)" href="DocList.aspx">文档</a></td>
    <td><a onmouseover="ShowMenu(menu8,100)" href="DocList.aspx">文档</a></td>
    </tr></table></body>

 

上面的内容是一个鼠标放上去就有个下拉菜单显示。现在的是做死了的,不能后台控制,可是,现在需要能够后台控制,所以要把整个菜单列表写成接口,别人给我传东西,用来控制它的显示。看看怎么弄??

原创粉丝点击