I got this jQuery script:
function changeImage(e) {
var nextImg = $(e).attr('nextImage');
var oldImg = document.getElementById('<%=imgMain.ClientID %>');
$(oldImg).attr('src', nextImg);
return false;
}
and this ASP.NET markup:
<asp:LinkButton runat="server" id="lbOne" Text="1" OnClientClick="changeImage(this); return false;" />
<asp:LinkButton runat="server" id="lbTwo" Text="2" OnClientClick="changeImage(this); return false;" />
Code behind:
lbOne.Attributes.Add("nextImage", "some_image");
lbTwo.Attributes.Add("nextImage", "some_image2);
some how it wont change the image src the jQuery script looks okay to me any ideas?
Found the error:
var oldImg = document.getElementById('<%=imgMain.ClientID %>');
need to add '#' like this:
var oldImg = document.getElementById('#<%=imgMain.ClientID %>');
works now. thanks for the comments!
<a>tags for this?