how to know which image button I click in datalist

后端 未结 1 439
后悔当初
后悔当初 2021-01-26 02:36

I want to change imageurl which image button I click in datalist.So I must get a diffence propertie of imagebutton in datalist.My code is below;



        
相关标签:
1条回答
  • 2021-01-26 03:01

    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";
    }
    
    0 讨论(0)
提交回复
热议问题