Solved

asp image with border around it

Posted on 2009-04-15
5
489 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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

749 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