Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old March 26th, 2008, 12:23 PM
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.

Reply With Quote
  #2 (permalink)  
Old March 27th, 2008, 04: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.

Reply With Quote
  #3 (permalink)  
Old March 27th, 2008, 07: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




Reply With Quote
  #4 (permalink)  
Old March 27th, 2008, 08: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
================================================== =========
Reply With Quote
  #5 (permalink)  
Old March 27th, 2008, 09: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

Reply With Quote
  #6 (permalink)  
Old March 27th, 2008, 09: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
================================================== =========
Reply With Quote
  #7 (permalink)  
Old March 27th, 2008, 11: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,413
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
Reply With Quote
  #8 (permalink)  
Old April 2nd, 2008, 07: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...

Reply With Quote
  #9 (permalink)  
Old April 2nd, 2008, 08: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
================================================== =========
Reply With Quote
  #10 (permalink)  
Old June 27th, 2016, 08: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
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 07:42 AM
Dynamically load new forms into Frames MichaelS Classic ASP Professional 0 July 11th, 2006 03: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 01:42 PM
How to split pages when content load dynamically bekim Classic ASP Basics 0 August 5th, 2004 03:57 AM



All times are GMT -4. The time now is 11:21 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.