how to know which image button I click in datalist

独自空忆成欢 提交于 2019-12-02 09:48:16

If you just want a change your selected image url, first of all you must add CommandName your ImageButton element as a below.

<asp:ImageButton ID="imgbtncevaponayla" runat="server" CommandName="btnimgbtncevaponayla" ImageUrl="~/resimler/cevaponaybeyaz.jpg"/>

You find which button selected on your .aspx.cs file and you change that image url like that:

if (e.CommandName == "btnimgbtncevaponayla")
{
    ImageButton btn = e.CommandSource as ImageButton;
    btn.ImageUrl = "~/resimler/different.jpg";
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!