Solved

WaterMark Image with javascript

Posted on 2008-06-18
5
1,519 Views
Last Modified: 2012-06-21
Hi all,
I have web application developed by asp.net 2.0 (VS 2005), I have a page displaying a table with thefollowing information: Car Model ,Description and Image.
In the Database i stored image as a path. and i use a datalist control to display these information as a table.

Challenge:
When a car is sold, then i want to display a stamp such as [SOLD] to be displayed over the image.
i tried many ways, such as javascript [attahed code snippet]. but the problem is:
When i minimize the browser the [SOLD]  displayed in the same position that because position:absolute.

<ItemTemplate>

        <br />

        <table border="1" style="width: 100px; height: 100px">

         <tr>

         <td style="width: 100px">

        <asp:Image ID="Image1" runat="server" Height="94px" ImageUrl='<%# Eval("img") %>'

        Width="134px" />

       <script type="text/javascript" language="javascript">

       var top;

       var left;

      top=document.getElementById("DataList1_ctl00_Image1").style.top;

      left=450;

     document.write("<font color='red'><div id='d1' style='left:"+left+"px; width: 100px; position: absolute; top:"+top+"px; height: 100px;font-size:50px;font-color:red'>[SOLD]</div></font>")

          </script> 

     </td>

    </tr>

</table>

<br />

</ItemTemplate>

Open in new window

0
Comment
Question by:Mremawi
  • 3
5 Comments
 
LVL 10

Accepted Solution

by:
bluefezteam earned 200 total points
ID: 21811892
You should use CSS for this - i did it for a property site.

<div class="imageHolder"><img src="car.jpg"/><img src="sold.jpg" class="sold"/></div>

.imageHolder {
display:block;
width:200px;
height:100px;
position:relative;
}
.imageHolder .sold {
position:absolute;
bottom:0;
left:0;
}

This will then holder a sold sign at the base of the image so you can still see the item on sale/sold but there's a sold image over it.

in action or a variation of it can be seen here

http://www.jhilditch.com/buy.html
0
 
LVL 10

Expert Comment

by:bluefezteam
ID: 21811895
If possible can you move this item to CSS ? it is a CSS related issue.
0
 
LVL 1

Author Comment

by:Mremawi
ID: 21837141
Dear bluefezteam:

thank you very much for your solution, but can I make the image sold in middle of car.jpg image?
0
 
LVL 10

Expert Comment

by:bluefezteam
ID: 21840629
yes - instead of bottom:0; you just need to know the height of your JPEG and divide that by 2, then remove the height of the sold.jpg divided by 2.

Eg

the car graphic is 100px high - its mid point is 50px.
The sold image that sits on the top is 30px - its mid point is 15px.

this means to get sold.jpg to appear over the middle of the the car.jpg you pocition it from TOP or BOTTOM by 50-15 = 35px.

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
In this tutorial viewers will learn how add a full-size background image to a webpage using CSS3. Create a new HTML document with an internal stylesheet.: In CSS, define the html element to have a background image. Use a high resolution image.: In t…
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…

911 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

16 Experts available now in Live!

Get 1:1 Help Now