Solved

asp image with border around it

Posted on 2009-04-15
5
499 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

696 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