How to assign imageurl to image button

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • PerumalSamy
    New Member
    • Feb 2007
    • 64

    How to assign imageurl to image button

    Hi,

    i had created image button and assigned image url as per the below code

    imagebutton1.im ageurl = server.mappath( "photo")+ "\" + imagefilename
    photo -> image folder in my project
    imagefilename -> retrieving from database(includ ing extension like .jpg,etc)

    and also i had created image button thru html coding as

    <img id="imgbtn" runat="server">

    and in codebehind page load event

    imgbtn.src = server.mappath( "photo")+ "\" + imagefilename

    but both the codings are working in local system but not in server.

    i checked path coding( server.mappath( "photo")+ "\" + imagefilename) by assigning to textbox. its working correctly but image is not displayed.

    deletion,creati on,updation everything is happening but only problem is displaying image.

    How can i resolve this problem.
  • shweta123
    Recognized Expert Contributor
    • Nov 2006
    • 692

    #2
    Hi,

    You can try for giving webpath for the ImageUrl
    e.g

    http://localhost/YourProject/imagefilename


    instead of
    server.mappath( "photo")+ "\" + imagefilename

    Comment

    • gomzi
      Contributor
      • Mar 2007
      • 304

      #3
      Originally posted by PerumalSamy
      Hi,

      i had created image button and assigned image url as per the below code

      imagebutton1.im ageurl = server.mappath( "photo")+ "\" + imagefilename
      photo -> image folder in my project
      imagefilename -> retrieving from database(includ ing extension like .jpg,etc)

      and also i had created image button thru html coding as

      <img id="imgbtn" runat="server">

      and in codebehind page load event

      imgbtn.src = server.mappath( "photo")+ "\" + imagefilename

      but both the codings are working in local system but not in server.

      i checked path coding( server.mappath( "photo")+ "\" + imagefilename) by assigning to textbox. its working correctly but image is not displayed.

      deletion,creati on,updation everything is happening but only problem is displaying image.

      How can i resolve this problem.
      How about trying this out ->
      imagebutton1.im ageurl = server.mappath( "photo/") & imagefilename

      Comment

      Working...