本文介绍了我如何用鼠标在asp.net中显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 嗨 我有这个代码 foreach (GridViewRow gr GridViewTn.Rows) { HyperLink hp = new HyperLink(); hp.Text = gr.Cells [ 1 ]。文字; hp.NavigateUrl = NarganTnFiles.aspx?Name = + hp.Text + - + gr.Cells [ 2 ] .Text + gr.Cells [ 5 ]。文字; gr.Cells [ 1 ]。Controls.Add(hp); } 当鼠标移动到一个项目上方时,我想要显示图像中的图片? < asp:Panel ID = Panel4 runat = 服务器 高度 = 100% style = margin-right:0px 宽度 = 100% 可见 = True > < 表格 > < tr > < td > < asp:GridView ID = GridViewTn runat = ser ver BorderStyle = 无 BorderWidth = 1px CellPadding = 2 ShowHeader = 真 样式 = text-align:center; margin-right:0px; > < / asp:GridView > < / td > < td 样式 = width:300px align = center > < asp:图像 ID = TnImage runat = server ImageAlign = 中间 高度 = 250 宽度 = 300 / > < / td > < / tr > < / table > < / asp:Panel > 解决方案 试试这样: foreach (GridViewRow gr in GridViewTn.Rows) { HyperLink hp = new HyperLink(); hp.Text = gr.Cells [ 1 ]。文字; hp.Attributes.Add( onmouseover, return showImg('img1.jpg');); hp.Atrributes.Add( onmouseout, 返回HideImg('img1.jpg');); hp.NavigateUrl = NarganTnFiles.aspx?Name = + hp .Text + - + gr.Cells [ 2 ]。文字+ gr.Cells [ 5 ]。文字; gr.Cells [ 1 ]。Controls.Add(hp); } 在aspx中javascript < script language = JavaScript type = text / javascript > function showImg(imgname) { // 从javascript显示图片或面板(在面板中加载图片) } 函数HideImg(Imagename) { // 隐藏图像或面板(在面板中加载图像)来自javascript } < / script > HiI have this Code foreach (GridViewRow gr in GridViewTn.Rows) { HyperLink hp = new HyperLink(); hp.Text = gr.Cells[1].Text ; hp.NavigateUrl = "NarganTnFiles.aspx?Name=" + hp.Text + "-" + gr.Cells[2].Text + gr.Cells[5].Text; gr.Cells[1].Controls.Add(hp); }I want when mouse move above one item show the picture in image?<asp:Panel ID="Panel4" runat="server" Height="100%" style="margin-right: 0px" Width="100%" Visible="True"> <table> <tr> <td> <asp:GridView ID="GridViewTn" runat="server" BorderStyle="None" BorderWidth="1px" CellPadding="2" ShowHeader="True" style="text-align: center; margin-right: 0px;" > </asp:GridView> </td> <td style="width: 300px" align="center"> <asp:Image ID="TnImage" runat="server" ImageAlign="Middle" Height="250" Width="300"/> </td> </tr> </table></asp:Panel> 解决方案 Try like this : foreach (GridViewRow gr in GridViewTn.Rows){HyperLink hp = new HyperLink();hp.Text = gr.Cells[1].Text ;hp.Attributes.Add("onmouseover", "return showImg('img1.jpg');");hp.Atrributes.Add("onmouseout", "return HideImg('img1.jpg');");hp.NavigateUrl = "NarganTnFiles.aspx?Name=" + hp.Text + "-" + gr.Cells[2].Text + gr.Cells[5].Text;gr.Cells[1].Controls.Add(hp);}In aspx javascript<script language="JavaScript" type="text/javascript">function showImg(imgname){// show image or panel (In panel load your image) from javascript}function HideImg(Imagename){ // Hide image or panel (In panel load your image) from javascript}</script> 这篇关于我如何用鼠标在asp.net中显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-12 00:16