Solved

asp image with border around it

Posted on 2009-04-15
5
451 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
Comment Utility
Try this solution:
http://vaultofthoughts.net/GettingRidOfASPNETImageControlBorder.aspx

I hope it will work for you.
0
 
LVL 10

Expert Comment

by:JPJ78
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
>>>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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now