使用GridView for imagebutton if else语句 [英] Using GridView for imagebutton if else statement
本文介绍了使用GridView for imagebutton if else语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望在单击图像按钮时使图像更改。我使用的是OnClick方法。
这是我尝试但不起作用的代码。
I want to make the image in imagebutton changes when it is clicked. I use the OnClick method.
This is the code I've tried but doesn't work.
protected void SignIn_Click(object sender, ImageClickEventArgs e)
{
if (ImageField.ThisExpression == this.ResolveClientUrl("~/Images/click.png"))
{
ImageButton.DisabledCssClass = this.ResolveClientUrl("~/Images/click.png");
}
}
推荐答案
我的解决方案是使用javascript并将其放在aspx页面之间。
My solution is to use javascript and place it in between the of the aspx page.
<script type="text/javascript">
function abc(signOut) {
var img = document.getElementById(signOut.id);
img.src = "/Images/click.png";
return false;
}
</script>
这是我在gridview中的图像按钮...
And this is my imagebutton in gridview...
<asp:TemplateField HeaderText="Sign Out">
<ItemTemplate>
<asp:ImageButton OnClientClick="return abc(this);" ID="signOut" CommandName="Insert" AlternateText="Available" ImageUrl="~/Images/unclick.png" runat="server" />
</ItemTemplate>
</asp:TemplateField>
这篇关于使用GridView for imagebutton if else语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文