how to change html image src by c# -


<img src ="~/usercontrols/vote/images/arrow up.png" id = "vote-up-off"          runat = "server" alt ="vote up"  class="voteupimage" style="height: 45px; width: 44px"/> 

here want change src of image condition like

if ( a==4) { src  url  shuld ...... } else {  src  url should be... } 

first need give id name can used variable:

<img src="~/usercontrols/vote/images/arrow up.png"       id="voteupoff"       runat="server" alt ="vote up"       class="voteupimage"       style="height: 45px; width: 44px" /> 

and in code behind use variable:

if (somecondition) {     voteupoff.attributes["src"] = resolveurl("~/usercontrols/foo.png"); } 

Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -