I'm trying to use images inside a Partial View like this:
<img src="~Content/Images/Layout/bild.jpg" />
This isn't working! When I view the code I can see that the path is changed to this:
<img src="/Views/Shared/~Content/Images/Layout/bild.jpg" />
Why this and how should I do get the right path for the images?
Always add the ~ (root) then (/) and the other path :
<img src="~/Content/Images/Layout/bild.jpg" />
and it's will work
Related
I have created a folder inside wwwroot, called Media. I'm trying to set a background image with css like this:
<body style='background-image: url("~/Media/background.png")'>
But the background does not appear.
However, if I try to put is as a image it works:
<img src="~/Media/background.png" />
So, how do I handle background images?
Try the following:
<body style="background-image: url(../Media/background.png)">
Maybe: try to use url of image instead of relative path.
In That case I suppose `https://yourdomain/media/background.png' could do the trick.
I'm using BatmanJs and Rails. I used carrierwave for uploading pictures and all worked fine. But, I am unable to show the image. The model has the attr photo.url which works fine. But I don't know how to bind a image tag.
I tried the following, with no result:
<img data-src="post.photo.url" />
<img data-bind="post.photo.url" />
But if I use
<span data-src="post.photo.url"></span>
it shows the url perfectly.
Kindly suggest how do i get it to work for img tag.
Very close! try data-bind-src. Actually, you can use data-bind-#{anything} to bind html attributes to keypaths.
I'm using Drupal 6.28 and there's something i don't understand.
i have a page that contains an image tag pointing to an absolute path.
e.g.
<img alt="google logo" src="http://www.google.com.sg/images/srpr/logo11w.png" style="height:190px; width:538px" />
when the content is saved, drupal returns a "Page Not Found" error.
i found out that if i remove the "http:" at the start of the src attribute, there wouldn't be any problem. everything would be ok.
i.e.
<img alt="google logo" src="//www.google.com.sg/images/srpr/logo11w.png" style="height:190px; width:538px" />
is there some setting that i may have messed up that causes this?
Thanks
I am storing images in a folder on a localhost for asp.net website.
The image is there and and the src attribute is correctly formed but the image is not displayed in img element.
can some body tell me what can be the issue or missing.. when I check the image in the url of brower it is displayed properly
localhost:xxxx/TenModified/setX/8fd7976b-d4b0-467a-bc3e-bf2a51d60299.Jpeg
This is my markup for the element
<img id="ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolderChild_ListViewThumbs_ctrl1_ctl03_Image1" src="localhost:59657/ProfileTenModified/setP/8fd7976b-d4b0-467a-bc3e-bf2a51d60299.Jpeg" style="border-width:1px;border-style:Solid;height:172px;width:172px;" alt="">
You don't need to include the domain and port. The following will work fine for the src:
/ProfileTenModified/setP/8fd7976b-d4b0-467a-bc3e-bf2a51d60299.Jpeg
or the full tag:
<img id="ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolderChild_ListViewThumbs_ctrl1_ctl03_Image1" src="/ProfileTenModified/setP/8fd7976b-d4b0-467a-bc3e-bf2a51d60299.Jpeg" style="border-width:1px;border-style:Solid;height:172px;width:172px;" alt="" />
use this:
src="ProfileTenModified/setP..."
full code:
<img id="ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolderChild_ListViewThumbs_ctrl1_ctl03_Image1" src="ProfileTenModified/setP/8fd7976b-d4b0-467a-bc3e-bf2a51d60299.Jpeg" style="border-width:1px;border-style:Solid;height:172px;width:172px;" alt="" />
You should remove the "localhost:59657" from the path. You really don't need it, just be root relative. This will save you a lot of time when you launch your application not having "localhost:59657" in there and just being root relative. You won't need to change all of your paths. Same holds true for any anchors. Make those root relative too.
<img id="ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolderChild_ListViewThumbs_ctrl1_ctl03_Image1" src="/ProfileTenModified/setP/8fd7976b-d4b0-467a-bc3e-bf2a51d60299.Jpeg">
Try to use Prefix. Http or Https
http:// localhost:xxxx/TenModified/setX/8fd7976b-d4b0-467a-bc3e-bf2a51d60299.Jpeg
<img src="http :// domain:port/TenModified/setX/8fd7976b-d4b0-467a-bc3e-bf2a51d60299.jpeg" />
Your link is is missing the two forward slashes in the protocol?
<img id="ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolderChild_ListViewThumbs_ctrl1_ctl03_Image1" src="localhost//:59657/ProfileTenModified/setP/8fd7976b-d4b0-467a-bc3e-bf2a51d60299.Jpeg" style="border-width:1px;border-style:Solid;height:172px;width:172px;" alt="" />
and also the slash for the closing of the image tag
I have used the below code to display image on top of the page. For condition1
div1.Visible = true;
div2.Visible = false;
For condition2,
div1.Visible = false;
div2.Visible = true;
and the code in the aspx page is like this.
<div id="div1" runat="server" style="padding-left: 110px;">
<img src="~/images/Package-Summary.gif" alt="Package Summary" />
</div>
<div id="div2" runat="server" style="padding-left: 110px;">
<img src="~/images/Process-Billing.gif" alt="Process Billing" />
</div>
Here it doesnot show me the image, instead shows an error box in that part!! What might be the reason!!!
I think you need a relative path to the image:
<img src="../images/Process-Billing.gif" alt="Process Billing" />
Your images are using server-side paths, but they're not server-side controls. The divs surrounding them are server-side controls, which doesn't affect the images. Either convert the image controls to server-side or convert the paths to something the client can request (relative paths, ideally).
Actually your images are not picking the right path as you are using server path at client side. If you want to use root-relative path you should use server side Image control to assign path.
You can use an Image server control and can just change its source but I do not know what you exactly want. But on client you use relative path not root-relative path. For root-relative path you have to use server image control.
see the article
ASP.NET Web Project Paths
so it should be
<div id="div1" runat="server" style="padding-left: 110px;">
<img src="../images/Package-Summary.gif" alt="Package Summary" />
</div>
<div id="div2" runat="server" style="padding-left: 110px;">
<img src="../images/Process-Billing.gif" alt="Process Billing" />
</div>
or where ever your image directory is you can go back to your image directory by just adding another "../" before path to go back to image directory.