Gridview ImageButton更改mouseover和mouseout上的图像
Gridview ImageButton change image on mouseover and mouseout
我有一个Gridview,其中有一个Imagebutton。它显示基于hfComplete(一个隐藏字段)值的图像。
如果值为true,则显示"images/completeiconfixed.png",并将属性附加到onmouseover"this.src='images/completieconfixed_transparant.png';"
如果为false,则显示"images/completeiconfixed_transparant.png",并将属性附加到onmouseout"this.src='images/completieconfixed.png';"
到目前为止,它第一次运行良好。它加载图像很好,当我第一次鼠标悬停时,它会更改图像,但第二次不会。
知道如何让它在每只老鼠身上工作吗。我的密码如下。
<asp:TemplateField HeaderText="C">
<ItemTemplate>
<asp:ImageButton ID="imgComplete" runat="server" CommandName="completeRecord"
CommandArgument='<%# Eval("TaskID") + "," + Eval("Completed")%>'
Height="16px" Width="16px"/>
</ItemTemplate>
<ItemStyle CssClass="mycol-md-3px mycol-xs-3px"></ItemStyle>
</asp:TemplateField>
protected void grdNetwork_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
ImageButton imgComplete = (ImageButton)e.Row.FindControl("imgComplete");
if (Convert.ToBoolean(hfCompleted.Value) == true)
{
imgComplete.ImageUrl = "images/completeiconfixed.png";
imgComplete.Attributes.Add("onmouseover", "this.src='images/completeiconfixed_transparant.png';");
}
else
{
imgComplete.ImageUrl = "images/completeiconfixed_transparant.png";
imgComplete.Attributes.Add("onmouseout", "this.src='images/completeiconfixed.png';");
}
}
}
提前谢谢。
您可以通过在以下两种情况下设置onmouseover
和onmouseout
来获得您想要的行为:
protected void grdNetwork_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
ImageButton imgComplete = (ImageButton)e.Row.FindControl("imgComplete");
if (Convert.ToBoolean(hfCompleted.Value))
{
imgComplete.ImageUrl = "images/completeiconfixed.png";
imgComplete.Attributes.Add("onmouseover", "this.src='images/completeiconfixed_transparant.png';");
imgComplete.Attributes.Add("onmouseout", "this.src='images/completeiconfixed.png';");
}
else
{
imgComplete.ImageUrl = "images/completeiconfixed_transparant.png";
imgComplete.Attributes.Add("onmouseover", "this.src='images/completeiconfixed.png';");
imgComplete.Attributes.Add("onmouseout", "this.src='images/completeiconfixed_transparant.png';");
}
}
}
相关文章:
- 如何使用url加载程序在webpack中导入多个图像
- nodejs-expressjs上传图像并显示它们
- 使用JSP从服务器检索和显示图像
- 音频控件在mouseover上显示,在mouseout上淡出
- 角度:在ng重复上切换图像
- 画廊图像未显示
- Phonegap-(安卓/iphone)多个图像的图像库出现问题
- Javascript排序的图像弹出窗口..可以't单独弹出
- 画布数据到图像
- Windows8应用程序(html&Javascript):从图片库(除了文件选择器)显示图像的另一种方式
- 使图像在单击时展开到不大于浏览器
- Html页面上的多个Base64图像和平滑加载
- UIAutomation放大图像
- 使用javascript在Flash中加载外部图像
- 可以在这里为背景图像设置滤镜吗
- 当图像转换为本地存储的DataURL时,EXIF被删除
- 使用 js 将背景图像设置为 HTML
- Gridview ImageButton更改mouseover和mouseout上的图像
- 我想更改图像'的mouseover和mouseout效果取决于调用了哪个函数
- 与用于mouseover()和mouseout()(图像交换)的attr混淆