setting an image path to an image button from c# CODE PLEASE HELP

hi im using for my web project and using c# my programming lang
the problem is
i have an image button on my web page. i have images saved on the server in a directory called Images. if i wanna change the image , i read the new image path from a datase and assign it to the image url.
but i am having a problem!

when ever i set the image path from the properties window
of the image button then it reads the correct directory on the server and
displays the image

but when i give the path from the c# code it doesnt show any image!
its like its not listening to the c# code when i do it through the code
coz when it runs on the server and if i give the path from the c# code i viewed the source of the page (the html code from ie browser) and it
shows nothing as the image url

in my code i have given the url like this:

ImageButton12.ImageUrl = "./Images/kiosk.jpg";

i tried this piece of code everywhere even in pageload method.

here how it looks like in the html code when it runs on the server

as u can see from the htmml code that has been generated , it never
assigns an image path .

but when i give the image url through image button's properties window (if i do like thiss i cant change the image at runtime)
then the image appears on the webpage and here how the html code of the
page looks like

now the image appears on the the web page

how come it never assigns a path to the image when it was given through
the c# code

please help me anyone i just dont unserstand what the hell is happening

saj :((


  • Hy saj.

    Don't cry man.

    You not using the asp controle... The code behind page doesn't have a referance to the contole.


    The key is the runat="server" property.
    See if you can make it work.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion