I have a template field that is supposed to toggle between keep and remove buttons and when i test it all the right alerts appear, if i click on keep then the alerts from changing it to remove appear and vice versa. my template field:
function changeButton(btnID, rowID) {
var imgPath = document.getElementById(btnID).src;
if (imgPath.indexOf('Keep.png') != -1) {
alert('going to change image to be: remove');
document.getElementById(btnID).src = '/SomeApplication/Global/Images/Mobile/Remove.PNG';
MyronCope
Participant
1656 Points
1345 Posts
image in gridview not changing
Nov 06, 2012 01:20 AM|LINK
using asp.net/vb.net 2010
I have a template field that is supposed to toggle between keep and remove buttons and when i test it all the right alerts appear, if i click on keep then the alerts from changing it to remove appear and vice versa. my template field:
<ItemTemplate> <table > <tr> <td> <img title="keep" id="prd<%#DataBinder.Eval(Container.DataItem, "PricingExID")%>" src="../../Global/Images/Mobile/Remove.png" alt="" onclick="changeButton('prd<%#DataBinder.Eval(Container.DataItem, "ProductID")%>', <%#DataBinder.Eval(Container.DataItem, "ProductID")%> )" > </img> </td> </tr> </table> </itemTemplate>and the javascript that it calls
function changeButton(btnID, rowID) {
var imgPath = document.getElementById(btnID).src;
if (imgPath.indexOf('Keep.png') != -1) {
alert('going to change image to be: remove');
document.getElementById(btnID).src = '/SomeApplication/Global/Images/Mobile/Remove.PNG';
alert('new path: ' + document.getElementById(btnID).src);
}
else {
alert('going to change image to be: keep');
document.getElementById(btnID).src = '/SomeApplication/Global/Images/Mobile/Keep.png';
alert('new path: ' + document.getElementById(btnID).src);
}
}
the alert always tells me that its going to switch paths but never does. i'm very puzzled about this.
any ideas on what I'm doing wrong?
thanks
MC
MyronCope
Participant
1656 Points
1345 Posts
Re: image in gridview not changing
Nov 06, 2012 02:12 AM|LINK
ok, its late here.
i had to keep the application name out of the function
the code above without "someApplication" text works well