在文本框焦点上选择/突出显示图像上的区域 [英] select/highlight area on image on textbox focus
问题描述
大家好,
我正在使用C#Web应用程序.我需要选择/突出显示文本框焦点上的图像上的某些区域,然后在焦点丢失时取消选择该区域.通过使用位图和Graphics对象,单击按钮就可以做到这一点.但是我不能在textbox onfocus事件上做同样的事情.
我用过以下写在静态服务器端函数内部的代码:
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 :
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();
并使用javascipt函数对其进行了调用.
我也尝试将上面的代码用于文本框焦点,但是我无法访问Server对象和Image1对象.
我对asp.net和javascript很陌生.任何帮助将不胜感激.
提前致谢.
Gitika Khurana
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
推荐答案
见下面的链接.可能会对您有帮助.
图像地图中的模式弹出窗口 [
Hi,
See below link. It might be help you.
Modal PopUp in Image map[^]
Thanks,
Viprat
您必须使用javascript中的某些库.
您必须使用"map"标签映射图像,并使用javascript对其进行动画处理.
这是使用jQuery的示例示例:
http://stackoverflow.com/questions/1201052/how-do-i-highlight-parts-of-imagemap-on-mouseover [ http://www.netzgesta.de/mapper/ [
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>
这篇关于在文本框焦点上选择/突出显示图像上的区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!