我试图更改ImageUrl onclick我的Repeater上的Imagebutton。我必须从代码(cs文件)后面更改它,而不是使用jquery或js。
<asp:ImageButton ID="imgLike" ImageUrl="Content/images/thumbsup.png" onclick="imgLike_Click" runat="server" style="width:25px;height:25px" />
这是代码
protected void imgLike_Click(object sender, ImageClickEventArgs e)
{
ImageButton imgLike = (ImageButton)rptinserting.FindControl("imgLike");
imgLike.ImageUrl = "Content/images/thumbsup1.png";
}
答案 0 :(得分:0)
您将发件人转发回ImageButton并更改ImageUrl
。
protected void imgLike_Click(object sender, ImageClickEventArgs e)
{
ImageButton imgLike = sender as ImageButton;
imgLike.ImageUrl = "/Content/images/thumbsup1.png";
}