Solved

asp image with border around it

Posted on 2009-04-15
5
471 Views
Last Modified: 2013-12-17
Hi,

I have the following code

asp.net
<div class="actualImageVid">
                    <a href="ShowCommentsforVideos.aspx?Video=<%#DataBinder.Eval(Container.DataItem,"Video_ID")%>">
                        <asp:Image ID="imgStartUpImagePath" runat="server" align="left" ImageUrl='<%#DataBinder.Eval(Container.DataItem,"StartUpImagePath")%>' />
                    </a>
                </div>

but when i run the page i find that it has the code below setting border to 0
<img id="ctl00_ContentPlaceHolder1_ListView1_ctrl0_ctl02_imgStartUpImagePath" align="left" style="border-width: 0px;" src="x.jpg"/>

which means that what i set in the css for the border property get over ridden I havenot used in line styling so how to i get rid of this border on the content placeholder

please help

Thanks,

R8VI
0
Comment
Question by:R8VI
5 Comments
 
LVL 25

Expert Comment

by:Luis Pérez
ID: 24147948
Try this solution:
http://vaultofthoughts.net/GettingRidOfASPNETImageControlBorder.aspx

I hope it will work for you.
0
 
LVL 10

Expert Comment

by:JPJ78
ID: 24147975
I'm not sure how to remove the "border-width: 0px" so that it is possible to use css, however you can set the border on the image with the properties
BorderWidth, BorderColor and BorderStyle or you can use a regular img html tag if you don't have to access the object from codebehind.

<div class="actualImageVid">
   <a href="ShowCommentsforVideos.aspx?Video=<%#DataBinder.Eval(Container.DataItem,"Video_ID")%>">
      <img style="float: left;" src='<%#DataBinder.Eval(Container.DataItem,"StartUpImagePath")%>' />
   </a>
</div>

Open in new window

0
 

Author Comment

by:R8VI
ID: 24148003
hi jp j78,

I think i might need to use an asp:image control as my backend c# has the following code

 ListViewItem eitm = e.Item;
        object MyColumnValue = ((DataRowView)(((ListViewDataItem)(eitm)).DataItem)).Row["StartUpImagePath"];

       
        Image image = (Image)e.Item.FindControl("imgStartUpImagePath");
        string filePath = MyColumnValue.ToString(); ;

        FileInfo fileInfo = new FileInfo(filePath);

        //append the '\' before the directory name

        DirectoryInfo directoryInfo = new DirectoryInfo(fileInfo.DirectoryName);

        string parentDir = string.Format(@"\{0}", directoryInfo.Parent);
        image.ImageUrl = "~" + (filePath.Substring(filePath.IndexOf(parentDir)));

this lets me trim off certain things of the string that comes out the database and put in fromt a ~ so it can be the root of the foler

Thanks,

R8VI
0
 
LVL 10

Accepted Solution

by:
JPJ78 earned 500 total points
ID: 24148492
You can use a function on the img tag to do this...
(I'm not a C# programmer so there might be some errors, but I hope you get the concept.)
<div class="actualImageVid">
   <a href="ShowCommentsforVideos.aspx?Video=<%#DataBinder.Eval(Container.DataItem,"Video_ID")%>">
      <img style="float: left;" src='<%#GetImageUrl(DataBinder.Eval(Container.DataItem,"StartUpImagePath"))%>' />
   </a>
</div>
 
public string GetImageUrl(string filePath)
{
        FileInfo fileInfo = new FileInfo(filePath);
 
        //append the '\' before the directory name
 
        DirectoryInfo directoryInfo = new DirectoryInfo(fileInfo.DirectoryName);
 
        string parentDir = string.Format(@"\{0}", directoryInfo.Parent);
        return "~" + (filePath.Substring(filePath.IndexOf(parentDir)));
}

Open in new window

0
 
LVL 22

Expert Comment

by:prairiedog
ID: 24152705
>>>which means that what i set in the css for the border property get over ridden
No, you don't have style for the image. Your CSS is set on the <div> tag, not on the image control.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question