Hello guys,
I have a small problem with setting the absolute path of an image.
Here is the scenario:
I need to put the image in a text concat something like this:
<asp:Label id = "lbl" runat = "server" text = "<img id = 'img' src =
'Images/picture.gif' /text " />
If I put a relative path everything is perfect, but if I try an
absolute path it is not working.
I have already tried:
<asp:Label id = "lbl" runat = "server" text = "<img id = 'img' src =
'/Images/picture.gif' /text " />
<asp:Label id = "lbl" runat = "server" text = "<img id = 'img' src =
'~/Images/picture.gif' /text
runat = 'server' " />
It seems like an easy thing to do but I cannot make it work.
Thanks for the help... 9 1535
'~/Images/picture.gif' will look for picture.gif in
'<rootweb>\Imag es\picture.gif'
In case, if you are using a virtual directory set up, your image will
actually be in '<rootweb>\<vir tual directory>\imag es\picture.gif' .
Hope this helps.
Regards,
Augustin
"Pumkin" <Po********@gma il.comwrote in message
news:11******** *************@c 28g2000cwb.goog legroups.com...
Hello guys,
I have a small problem with setting the absolute path of an image.
Here is the scenario:
I need to put the image in a text concat something like this:
<asp:Label id = "lbl" runat = "server" text = "<img id = 'img' src =
'Images/picture.gif' /text " />
If I put a relative path everything is perfect, but if I try an
absolute path it is not working.
I have already tried:
<asp:Label id = "lbl" runat = "server" text = "<img id = 'img' src =
'/Images/picture.gif' /text " />
<asp:Label id = "lbl" runat = "server" text = "<img id = 'img' src =
'~/Images/picture.gif' /text
runat = 'server' " />
It seems like an easy thing to do but I cannot make it work.
Thanks for the help...
Thank you for your interest and for the reply.
The problem is that if I put :
Text="<img id='img1' runat = 'server' src = '~/Images/picture.gif' />
Text"
and if I look in View Source in IE I can see that it doesn't put any
path at all:
Text="<img id = 'img1' src='~/Images/picture.gif' alt='' runat =
'server' /> Text"
And if I put the realtive path it understands the path corectly.
Any ideas?
Lets say that my web site is on localhost and has the virtual directory
MyWebSite.
Of course if I set the path src '
"http://localhost/MyWebSite/Images/picture.gif" it is working.
But I was wondering if there isn't a better way to do this.
Regards,
it will not put any path if you use '~\Images'. It knows where to look for..
Can you try putting in '..\Images\pict ure.gif' and tell me if this works?
Regards,
Augustin
"Pumkin" <Po********@gma il.comwrote in message
news:11******** **************@ m7g2000cwm.goog legroups.com...
Thank you for your interest and for the reply.
The problem is that if I put :
Text="<img id='img1' runat = 'server' src = '~/Images/picture.gif' />
Text"
and if I look in View Source in IE I can see that it doesn't put any
path at all:
Text="<img id = 'img1' src='~/Images/picture.gif' alt='' runat =
'server' /> Text"
And if I put the realtive path it understands the path corectly.
Any ideas?
If I put '..\Images\pict ure.gif' it works.
But the img is in a user control and it is used in 2 pages.
And depending on the page that it is used I need to have as path
'..\Images\pict ure.gif' and '..\..\Images\p icture.gif'. So I cannot
really used a relative path. :)
in this case, you can use ~\Request.Appli cationPath\Imag es\Picture.gif. . you
can set this from code behind.. Hope this helps.
"Pumkin" <Po********@gma il.comwrote in message
news:11******** **************@ i3g2000cwc.goog legroups.com...
>
If I put '..\Images\pict ure.gif' it works.
But the img is in a user control and it is used in 2 pages.
And depending on the page that it is used I need to have as path
'..\Images\pict ure.gif' and '..\..\Images\p icture.gif'. So I cannot
really used a relative path. :)
Thank you very much for the solution offered.
But I would rather not put the path from code-behind if possible (it is
really difficult to do this in my situation).
Is there other solution (from HTML) ??
Sorry for so many questions here...
Regards,
Pumkin
Thank you very much for the solution offered.
But I would rather not put the path from code-behind if possible (it is
really difficult to do this in my situation).
Is there other solution (from HTML) ??
Sorry for so many questions here...
If you realy need this weird construction, you can use data-binding:
<asp:Label ID="MyLabel" Text="<%# "<img src='" +
ResolveUrl("~/images/myImage.gif") + "' alt='xxx' />" %>" runat="server" />
....and don't forget to call MyLabel.DataBin d() or Page.DataBind() form code.
Robert Haken [MVP ASP/ASP.NET]
HAVIT, s.r.o., www.havit.cz http://knowledge-base.havit.cz
It seems it is hopeless.. In the situation that I am having I cannot
use server directives to set the path.
To detail a little bit more the control in which I want to put the
image is not a label,
but the atlas control expandable panel and it doesn't allow me to put
server code.
Thanks for the help everybody anyway. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: dchaffin |
last post by:
I'm having a problem using file_exists with an absolute path and I can
not figure out why.
I tried the exact example that is on www.php.net ...
<?php
$filename = '/path/to/foo.txt';
if (file_exists($filename)) {
echo "The file $filename exists";
|
by: rajuvk |
last post by:
I am setting up a website with a number of folders like:
/ (the document root)
/user
/admin/
/content
in the /user folder there is a flie "userlogged.php", which I want to
include in every file. If in the file "/content/index.php", if I use
the relative path and place the include like this
"../user/userlogged.php", it will work fine. But when I use the
absolute path like "/user/userlogged.php", it is not working ?. I have
|
by: Stuart |
last post by:
Hi All,
I got a challenge to make the same APS/Script/Html run on different web
roots. I can not use relative pathing in a lot of cases. We use lots of
included files so depending on where that file is running, the pathing in
those included files varies. So we do a lot of absolute pathing.
Example: Instead of Mappath("../../../_scripts/menu/mymenuscript.js") we use
mappath("/_scripts/menu/mymenuscript.js").
In one case, the code is...
|
by: Nick K. |
last post by:
I recently began maintenance work on a production web server that is located
in the root directory of a web server. I moved this into a sub web on my
local web server in order to do work on it. I found that there is an include
file that references images:
<img src = "/images/Header.gif"
What worked correctly on the production server breaks on mine because of the
absolute address "/images". I removed the absolute address and changed...
|
by: William Starr Moake |
last post by:
Another problem with absolute paths in the WYSIWYG editor I'm putting
together.
The function to toggle between WYSIWYG and HTML modes works except for
one glitch. If you use a relative path for a link, like <a
href="download.htm">Click Here</a>, the editor returns an absolute
path the second time you toggle HTML mode: <a
href="C:\Windows\Desktop\Editor\download.htm" and even adds file:///
on the third try. This path must be manually...
| |
by: JeffDotNet |
last post by:
I wrote a small data processing application that writes a summary of
several hundred files. I use drag and drop on a panel (Panel1) to grab
the absolute path to each of these files. Then I begin analyzing all of
the files. I noticed (on the same machine) that some user profiles
appear to abbreviate the absolute paths to these files thus breaking my
data loading mechanism. Does anyone know how I can programmatically
change this filepath...
|
by: Jerry M. Gartner |
last post by:
Greetings:
What is the best way to resolve paths within a document regardless of what
path it is opened under? For example: I have x.php and it contains <img
src="images...">, (amongst other things, like php code), which resolves the
correct image path when opened under / but when x.php is read into a file
under /dir the image no longer resolves, for obvious reasons. With absolute
paths, this isn't an issue but it is with relative...
|
by: Jon Slaughter |
last post by:
do I have to prefix every absolute path with document root to get it to
work?
For some reason I thought that prefixing a path with '/' or './' with make
it absolute w.r.t to document root but I guess not?
e.g., when I do
include './Scripts/AddNav.php';
|
by: SETT Programming Contest |
last post by:
The SETT Programming Contest: The fastest set<Timplementation
Write the fastest set<Timplementation using only standard C++/C.
Ideally it should have the same interface like std::set.
At least the following methods must be implemented:
insert(), find(), begin(), end(), erase(), size(), operator<(),
and at least the forward iterator.
Here, speed and correctness are the 2 most important factors.
Functionally it should behave similar to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |