0

I have a page with several image buttons within a gridview, the girdview is 40 - 50 rows. I need to change the "src" value which contains the URL of the image to another value. I need to do this to all img buttons with the SAME src. Example:

<input type="image" name="ctl00$ctl00$MainContent$ContentPlaceHolderMain$gv$ctl06$ctl02" src="../../Images/someimage.gif" onclick="dosomething();" style="border-width:0px;" />

<input type="image" name="ctl00$ctl00$MainContent$ContentPlaceHolderMain$gv$ctl07$ctl02" src="../../Images/someimage.gif" onclick="dosomething();" style="border-width:0px;" />

<input type="image" name="ctl00$ctl00$MainContent$ContentPlaceHolderMain$gv$ctl08$ctl02" src="../../Images/someimage.gif" onclick="dosomething();" style="border-width:0px;" />

<input type="image" name="ctl00$ctl00$MainContent$ContentPlaceHolderMain$gv$ctl09$ctl02" src="../../Images/someimage.gif" onclick="dosomething();" style="border-width:0px;" />

<input type="image" name="ctl00$ctl00$MainContent$ContentPlaceHolderMain$gv$ctl10$ctl02" src="../../Images/someimage.gif" onclick="dosomething();" style="border-width:0px;" />

<input type="image" name="ctl00$ctl00$MainContent$ContentPlaceHolderMain$gv$ctl11$ctl02" src="../../Images/someimage.gif" onclick="dosomething();" style="border-width:0px;" />

I need to do search for "../../Images/someimage.gif" and replace it with another path. I've looked up this answer and there are ways to find the "src" field based on but this is a image button "type='image'"

John
  • 193
  • 1
  • 1
  • 11
  • The duplicates contain the solution you need, however there's some other problems you need to address: 1) There's no need for those ugly auto-generated `name` attributes if you're still having to use c# WebForms - especially not for controls which aren't `runat="server"`. 2) Use unobtrusive event handlers in your JS code, not outdated `onclick` etc. attributes in your HTML. 3) Do not put CSS style in `style` attributes your HTML - use an external stylesheet – Rory McCrossan Dec 29 '22 at 19:57

0 Answers0