Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
| Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old March 26th, 2008, 11:23 AM
Authorized User
 
Join Date: May 2007
Location: Dar es Salaam, , Tanzania.
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to jazzydonald
Default How to load images dynamically on image control

I have an asp.net application that let user retrieve some infomation from a database and display a corresponding image stored on a folder somewhere in my pc.
The user enters a checkno and the application display records from db and an image. So far am able to get the full path of that image but i do not know how to pass that path to an image control at runtime. I didnt want to use '~\....' to specify image url at design time because my images can reside somewhere on pc or server etc. Can somebody help.

  #2 (permalink)  
Old March 27th, 2008, 03:13 AM
Authorized User
 
Join Date: Mar 2008
Location: Ahmedabad, Gujarat, India.
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi,

you can do it at runtime like :

image1.imageurl="fullpath"

thats it.

  #3 (permalink)  
Old March 27th, 2008, 06:45 AM
Authorized User
 
Join Date: May 2007
Location: Dar es Salaam, , Tanzania.
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to jazzydonald
Default

Thanks imjigu2001 for the reply.
I tried that but it didnt display any image. I even tried to put the path at design time it didint work. Heres the code;

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Image1.ImageUrl = "C:\Documents and Settings\Mangulu\My Documents\coseke logo.jpeg"
End Sub




  #4 (permalink)  
Old March 27th, 2008, 07:28 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Hmm. That is a bad practice to have an image link like that. That may very well be where the image resides on your machine but it really needs to be placed in the folder where your website resides because, if you were to purchase hosting from someone, that is not where the image will reside at all.

consider this directory structure

-WebFolder
-----Images
----------coseke logo.jpeg
-----YourPage.aspx

If your image control resides on YourPage.aspx the ImageURL could be any of the following:
./Images/coseke logo.jpeg
Images/coseke logo.jpeg <--This would only work if you were actually working in a domain and not off of localhost
~/Images/coseke logo.jpeg

hth.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========
  #5 (permalink)  
Old March 27th, 2008, 08:38 AM
Authorized User
 
Join Date: May 2007
Location: Dar es Salaam, , Tanzania.
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to jazzydonald
Default

Thanks dparsons for the useful infomation. I'll try to follow that practise. cheers

  #6 (permalink)  
Old March 27th, 2008, 08:54 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

It is worth noting that that the tildea character (~) will only work on controls that have the attribute runat="server".

This isn't a problem in your situation since you are using an image control but this will bomb if you try to use a standard HTML img tag.

-Doug

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========
  #7 (permalink)  
Old March 27th, 2008, 10:42 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

As Doug suggests, you need to be careful where you try to use the ~ character.

Many server controls will process that character appropriately. But when you need to use a app root relative path in a non server control you can still process it manually. For example:

string correctUrl;
correctUrl = ResolveUrl("~/images/someimage.jpg");

You can now use that resolved url in plain HTML or in a control that may not process the ~ itself.

-Peter
peterlanoie.blog
  #8 (permalink)  
Old April 2nd, 2008, 06:36 AM
Authorized User
 
Join Date: May 2007
Location: Dar es Salaam, , Tanzania.
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to jazzydonald
Default

if my images are on the server and my application is on the same server how would i do it.(load images on my page) i.e the codes...

  #9 (permalink)  
Old April 2nd, 2008, 07:16 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

I don't understand. Did my suggestions not work? What have you tried?

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========
  #10 (permalink)  
Old June 27th, 2016, 07:14 AM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2016
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default load images dynamically on image control

Hi guys

Here is some useful resources about how load images dynamically on image control

Check this link

https://www.mindstick.com/Articles/4...in-asp-dot-net




Similar Threads
Thread Thread Starter Forum Replies Last Post
Load Images from and Save Images to a Database cyndie VB.NET 2 August 17th, 2008 06:42 AM
Dynamically load new forms into Frames MichaelS Classic ASP Professional 0 July 11th, 2006 02:59 PM
How to load image Edit control cyberrider VB How-To 1 November 4th, 2005 02:25 PM
how to load images vaneza VB How-To 3 August 2nd, 2005 12:42 PM
How to split pages when content load dynamically bekim Classic ASP Basics 0 August 5th, 2004 02:57 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.