Click here to Skip to main content
15,913,198 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All,

I am working on a C# web application. I need to select/highlight some area on an image on focus of a textbox, and then de-select the area when the focus is lost. I have been able to do so on click of a button, by using bitmap and Graphics object. But I cant do the same on textbox onfocus event.

I had used the following code written inside a static server side function :

C#
Bitmap bmp = (Bitmap)Bitmap.FromFile("~/Images/SampleDoc.jpg");
Graphics g = Graphics.FromImage(bmp);

Pen snowPen = new Pen(Color.Blue, 2);
g.DrawRectangle(snowPen, 600, 225, 100, 30);
//g.DrawRectangle(Pen, x, y, width, height);

String path = Server.MapPath("~/Images/DrawRectangle.jpg");
bmp.Save(path, ImageFormat.Jpeg);

Image1.ImageUrl = "~/Images/DrawRectangle.jpg";
g.Dispose();
bmp.Dispose();


and called it using a javascipt function.

I tried using the code above for a textbox focus too but I wasn't able to access the Server object and Image1 object.

I am pretty new to asp.net and javascript. Any help will be much appreciated.

Thanks in advance.

Gitika Khurana
Posted

Hi,

See below link. It might be help you.

Modal PopUp in Image map[^]

Thanks,
Viprat
 
Share this answer
 
Comments
gitika.khurana 7-Sep-12 6:17am    
I am not looking for the functionality offered by ImageMap. I don't need to click anywhere on the image. All I want is to be able to highlight some area on the image, not create a hotspot.
You have to use some library in javascript.
You have to map the image with "map" tag, and use javascript for animate it.

this is a sample example using jQuery:
http://stackoverflow.com/questions/1201052/how-do-i-highlight-parts-of-an-imagemap-on-mouseover[^]

you can also search on google, or visit this project:
http://www.netzgesta.de/mapper/[^]</map>
 
Share this answer
 
v2
Comments
gitika.khurana 10-Sep-12 3:08am    
Thanks for the reply, but it doesn't really solve my purpose. Image maps work with mouseover, and I am looking for image area highlight on textbox focus.
cpsglauco 20-Sep-12 9:07am    
if you read some example from the netzgesta library, you will find scripts that fit your needs

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900