ASP.NET結合JS在圖層上顯示記錄資訊

來源:互聯網
上載者:User

JS檔案(這裡命名為Function.js)

function MM_reloadPage(init)
{ //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d)
{ //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers()
{ //v6.0
var i,p,v,obj,args=MM_showHideLayers.arguments;
for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
obj.visibility=v; }
}

在DataGrid中建模板列

<asp:TemplateColumn>
<ItemTemplate>
<div onMouseOver="MM_showHideLayers('layer<%# DataBinder.Eval(Container, "DataItem.f_ID") %>','','show')" onMouseOut="MM_showHideLayers('layer<%# DataBinder.Eval(Container, "DataItem.f_ID") %>','','hide')">
<font color=blue><U>詳細資料</U></font>
</div>
<span id='layer<%# DataBinder.Eval(Container, "DataItem.f_ID") %>' style="position:absolute; left=420; top:100; width:300; z-index:1; layer-background-color: #FFFFCC; border: 1px none #000000; visibility: hidden;">
<table width="100%" border="0" cellpadding="10" cellspacing="1" bgcolor="#000000">
<tr>
<td bgcolor="#FFFFCC">
<%# DataBinder.Eval(Container, "DataItem.f_Memo") %>
</td>
</tr>
</table>
</span>
</ItemTemplate>
</asp:TemplateColumn>

在你的aspx檔案中包含<script src=Function.js></script>(假如JS檔案與你的aspx檔案在同一目錄下),上面模板列中的f_ID是要顯示表的主鍵(也就是DataGrid中的DataKeyField),f_Memo是使用者移動滑鼠到“詳細資料”上時彈出的資訊。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.