adding / to internet address causes asp:Image not loading - html

My code:
<asp:Image runat="server" alt="not loaded" ImageUrl="picture.png" />
On site address
example.com/tabid/233/Default.aspx
everything works, but on address ("/" added)
example.com/tabid/233/Default.aspx/
my page looks like before but picture is not loaded. Does somebody can explain it to me and give an adive what to do to have picture always loaded?

If image in root u can map image like this.
<asp:Image runat="server" alt="not loaded" ImageUrl="~/picture.png" />

Default.aspx is your page and Default.aspx/ references to a folder. If you want to use / at the and, you can try routing or apply rewrite rules.
http://msdn.microsoft.com/en-us/magazine/dd347546.aspx

Change the "ImageUrl" attribute in the Image tag to something like...
<asp:Image runat="server" ImageUrl="~/picture.png" />
The extra "/" has the browser looking a folder deeper than it should be for the image.

Related

HTML - TelerikLiveTile center of page

i want to center some telerik:RadLiveTile elements on my Page, but i dont know how. I've tried many ways found with google but nothing works for me.
Attached, you can find my imagination of the page.
PAGE
One tile looks like this:
<telerik:RadLiveTile
ID="thridTile"
runat="server"
Width="600"
Height="300"
UpdateInterval="5000"
OnClientDataLoadingError="liveTileOnClientDataLoadingError"
OnClientTemplateDataBound="liveTileOnClientTemplateDataBound"
Shape="Wide">
<WebServiceSettings Path="WebService.asmx" />
<ClientTemplateAnimationSettings Animation="None" />
<ClientTemplate>
#=data#
</ClientTemplate>
</telerik:RadLiveTile>
Greetings, Marvin

Image not show asp.net

If I run my webapplication the application work right. When I try to publish with the file system the images doesn't show. The images are included in project and in the publish folder I do find the images in the image folder.
but is does not show. There is no error, so I do not know where I had to look. Does somebody can help me with this? The image is a simple html tag.
<img src="~/Images/logo.png">
You can not mix ~ with non runat="server" control :
But you can do this :
<img src='<%= ResolveUrl("~/Images/logo.png") %>'/>
MVC :
<img src="#Url.Content("~/Images/logo.png" )"
Is it an ASP.NET webform project? If so, update it as follows:
<img src="~/Images/logo.png" runat="server" />
Here are two ways to set up your image. Either one should work for you.
<img src="/Images/logo.png" />
<asp:Image ID="Image1" ImageUrl="~/Images/logo.png" runat="server" />

Not able to include image in html using relative path

i have a porlet running in liferay portal.after successfully entering the details , i want to download the details in an html page , in which i have to include an image.
this is done by giving the absolute path as:
<img src="http://localhost:8080/Demo-portlet/images/logo-1.jpg"
and it works fine.
My portlet structure is :
Demo-portlet-->docroot-->images-->logo-1.jpg
Now i want to do this by using relative path. i tried as below but it didnt work out:
<img src="../Demo-portlet/docroot/images/logo-1.jpg" />
<img src="./docroot/images/logo-1.jpg" />
<img src="./images/logo-1.jpg" />
None of the above worked. please tell me how this can be done.
Adding the html path:
Demo-portlet-->docroot-->download.html
Try this:
<img src="images/logo-1.jpg" />
Your portlet can be embedded on random pages. It's the page's URL that you need to be relative to, not the portlet.
If you have your portlet on http://localhost:8080/web/guest/home or http://localhost:8080/web/guest/about-us/contact/addresses, the relative address would need to be different. Thus I'd recommend to be relative with regards to the server name, but not with regard to the embedding URL: At development time you have no clue what name the pages that embed your portlet will have.
Go with <img src="/Demo-portlet/images/logo-1.jpg" /> or look up the servlet context (e.g. replace "/Demo-Portlet" with a dynamic value, so that you don't have to hard-code it).
(sorry, IDE not running and I'm always mixing up if it's request.getServletContext() or something else - try for yourself and comment here, I'll edit this answer when you give the full code). The dynamic stuff - on a jsp - would be <img src="<%=request.getServletContext()%>/images/logo-1.jpg" />

image is not displayed in html page?

I am using html. inside a table i have to display a logo. PFB code.
<table>
<tr>
<td>
<img src="C:\Documents and Settings\user\Desktop.company.jpg" />
</td>
</tr>
</table>
but image is not displayed. instead a blank image is displayed as below.
what is wrong with my code? why actual image is not displaying here? Please help me.
Thanks!
Your image path refers to your C:/ disk. Your C:/ disk is not accessible by everyone on the internet (I might hope).
I suggest you read this before you publish your website: http://www.webreference.com/html/tutorial2/3.html
image tag take 2 type of value of src attribute
1) relative path
2) server path
your path is not allowed
make folder name "images" in same directory where your file is and put image into it
give src like this <img src="images\Desktop.company.jpg" />
If your image name is company.jpg then it should be
<img src="C:\Documents and Settings\user\Desktop\company.jpg" />
and not
<img src="C:\Documents and Settings\user\Desktop.company.jpg" />
write code like below and see your problem solved
file:///C:\Documents and Settings\user\Desktop\company.jpg

Image is not showing in browser?

<body style="background-color: paleturquoise">
<h2 style="color: red">Duke's soccer League: Home Page<br/></h2>
<ul style="list-style-type: circle">
<li style="font-size: larger">All Leagues list</li>
<li style="font-size: larger">Register for a League (TBA)<br/><br/></li>
</ul>
<h2 style="color: red">League Administrator</h2>
<ul style="list-style-type: square">
<li style="font-size: larger">Add a new League (TBA)</li>
<img src="C:\Users\VIRK\Desktop\66.jpg" width="400" height="400" ></img>
</ul>
</body>
I am currently practice with JSP and I try this html code to make a web page on NetBeans IDE 7.0 but when I'm build and run the page no error in code but the image is not showing in the browser.
Edited:
Here I have given the screenshot of the NetBeans IDE where you can see the image is existing in Web-INF folder and the index.jsp page too and I tried with "/" before the image name but it won't work. The exact path of my project is C:\Users\VIRK\Documents\NetBeansProjects\practiceJSP .
<img src="/66.jpg" width="400" height="400" ></img>
I find out the way how to set the image path just remove the "/" before the destination folder as "images/66.jpg" not "/images/66.jpg" And its working fine for me.
You put inside img tag physical path you your image. Instead of that you should put virtual path (according to root of web application) to your image. This value depends on location of your image and your html page.
for example if you have:
/yourDir
-page.html
-66.jpg
in your page.html it should be something like that:
<img src="66.jpg" width="400" height="400" ></img>
second scenario:
/images
-66.jpg
/html
page.html
So your img should look like:
<img src="../images/66.jpg" width="400" height="400" ></img>
Your path should be like this : "http://websitedomain//folderpath/66.jpg">
<img src="http://websitedomain/folderpath/66.jpg" width="400" height="400" ></img>
I don't know where you're running the site from on your computer, but you have an absolute file path to your C drive: C:\Users\VIRK\Desktop\66.jpg
Try this instead:
<img src="[PATH_RELATIVE_TO_ROOT]/66.jpg" width="400" height="400" />
UPDATE:
I don't know what your $PROJECTHOME is set to. But say for example your site files are located at C:\Users\VIRK\MyWebsite. And let's say your images are in an 'images' folder within your main site, like so: C:\Users\VIRK\MyWebsite\images.
Then in your HTML you can simply reference the image within the images folder relative to the site, like so:
<img src="images/66.jpg" width="400" height="400" />
Or, assuming you're hosting at the root of localhost and not within another virtual directory, you can do this (note the slash in the beginning):
<img src="/images/66.jpg" width="400" height="400" />
all you need to do is right click on the jsp page in the browser, which might look like "localhost:8080/images.jpg, copy this and paste it where the image is getting generated
I had same kind of problem in Netbeans.
I updated the image location in the project and when I executed the jsp file, the image was not loaded in the page.
Then I clean and Built the project in Netbeans. Then it worked fine.
Though you need to check the image actually exists or not using the image URL in the browser.
I had a problem where the images would not show and it wasn't the relative path. I even hard coded the actual path and the image still did not show. I had changed my webserver to run on port 8080 and neither
<img src="c:/public/images/<?php echo $image->filename; ?>" width="100" />
<img src="c:/public/images/mypic.jpg" width="100" />
would not work.
<img src="../../images/<?php echo $photo->filename; ?>" width="100" />
Did not work either. This did work :
<img src="http://localhost:8080/public/images/<?php echo $image->filename; ?>" width="100" />
do not place *jsp or *html in root folder of webapp and images you want to display in same root folder browser cannot acess the image in WEB-INF folder
I also had a similar problem and tried all of the above but nothing worked.
And then I noticed that the image was loading fine for one file and not for another. The reason was: My image was named image.jpg and a page named about.html could not load it while login.html could. This was because image.jpg was below about and above login. So I guess login.html could refer to the image and about.html couldn't find it.
I renamed about.html to zabout.html and re-renamed it back. Worked.
Same may be the case for images enclosed in folders.
the easy way to do it to place the image in Web Content and then right click on it and then open it by your eclipse or net beans web Browser it will show the page where you can see the URL which is the exact path then copy the URL and place it on src=" paste URL " ;
If we are using asp.net "FileUpload" control and want to preview image before upload we can use below code.
<asp:FileUpload ID="fileUpload" runat="server" Style="border: none;" onchange="showpreview(this);" />
<img id="previewImage" src="C:\fakepath\natureImage.jpg">
<script>
function showpreview(Imagepath) {
var reader = new FileReader();
reader.onload = function (e) {
$("#previewImage").attr("src", e.target.result);
}
reader.readAsDataURL(Imagepath.files[0]);
}
</script>
Another random reason for why your images might not show up is because of something called base href="http://..." this can make it so that the images file doesn't work the way it should. Delete that line and you should be good.
You need to import your image from the image folder.
import name_of_image from '../imageFolder/name_of_image.jpg';
<img src={name_of_image} alt=''>
Please refer here.
https://create-react-app.dev/docs/adding-images-fonts-and-files -
The folder names in the path should not contain the space
write fullstack /asset/image.jpg instead of full stack/asset/image.jpg