473,488 Members | 2,464 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Drawing a rectangle on a web page

Hello,

I'm trying to draw a rectangle on a web page which
contains a picture. Following is the function for a
similar windows application.

private void ZoomIn_Click(object sender,
System.Web.UI.ImageClickEventArgs e)
{
System.Drawing.Graphics g ;
g = Graphics.FromHwnd(this.MapImage.Handle) ;
Rectangle TheRect = GetTheRectangle(StartBoxPoint,
EndBoxPoint) ;
g.DrawRectangle(this.ThePen, TheRect) ;
RefreshImage(StartBoxPoint.X, StartBoxPoint.Y,
EndBoxPoint.X, EndBoxPoint.Y) ;
g.Dispose();
}

When I'm building the solution its giving me an error
System.Web.UI.Webcontrols.Image doesn't contain a
definition for handle.

Can anyone please help me on this issue?

Regards,
Ryan
Nov 16 '05 #1
3 9079
"Ryan" <an*******@discussions.microsoft.com> wrote in message news:09****************************@phx.gbl...
I'm trying to draw a rectangle on a web page which
contains a picture. Following is the function for a
similar windows application. : : When I'm building the solution its giving me an error
System.Web.UI.Webcontrols.Image doesn't contain a
definition for handle.


There are a number of fundamental differences between Windows
(rich client) graphics and Web (thin client) graphics. You pretty
much have to either (a) throw out that Windows code altogether,
or (b) salvage it perhaps by using WinForms graphics code to
render drawings to a Bitmap and then save off that Bitmap (as
a .jpg, .gif, or other graphics file format) to some location on the
web server that clients can reach (be careful if you do save a
file from your Web application that the ASPNET account has
security privileges granted to it sufficient enough to create the
image file on the server's file system).

If there's a dynamically generated image file on the server for the
Web Form to refer to using an IMG tag, then it's simply a matter
of rendering <IMG SRC="url_of_your_graphics_file.png" /> out to
the HTTP response stream when the page renders. This still carries
the problem of how to clean-up after such dynamically generated
files, though (because of ASP.NET's inherent statelessness).

Nothing in that Windows function will give you a clue about the Web
environment. In an ASP.NET WebForms application, you much
render HTML markup to the client's web browser -- this is all text
that describes what the page should look like. Browsers like Internet
Explorer, Mozilla, and Firefox all interpret the HTML and display it
to your end user (sometimes these browsers will interpret the HTML
in varied and unexpected ways! Web progamming isn't just a job,
it's a neverending epic adventure ...) Usually they create peer con-
trols using the end user's own operating system's rich graphics sub-
system, that correspond to HTML elements that a user can interact
with. However, the exact characteristics of a button to a user on
Internet Explorer / Windows XP with an Olive color scheme will
differ from the appearance of a button to a user on Firefox /
Macintosh. As a web developer, you usually don't have control
over what peer exactly the browser chooses to represent your
HTML elements as.

To draw a box in HTML, you would render this markup,

<table border="1"><tr><td>&nbsp;</td></tr></table>

What you could do in Visual Studio .NET is create a Web
Custom Control library (using that project type), override
the Render method in the class file it produces for you to
write that string above to the HtmlTextWriter argument it
receives, then build this library. Next, open the Toolbox
with Control-Alt-X key, and Customize one of the tabs,
so that you can Add a .NET Framework component.
Browse until you find the .dll file that you just created,
the Custom Control library, and drag and drop that
onto your WebForm1.aspx's Design View. You should
see a preview of the box at design-time, similar to what
it would look like at run-time.

Other subjects you may want to investigate for more
information are VML (Vector Markup Language) and
it's successor, SVG (Scalable Vector Graphics). VML
is obsolete but it has the benefit of being built-in to Internet
Explorer 5 (but no other brands of browser). SVG is the
heir to the throne, but it still requires that you install a plug
in to make your browser display SVG (Adobe offers one
free plug-in for SVG on Internet Explorer, there are also
other plug-ins out there for SVG on Mozilla and Firefox
brands of browser.) Until you have a tighter grasp of the
differences between ASP.NET and WinForms, rushing
headlong into these specialty markup languages may be
premature though.
Derek Harmon
Nov 16 '05 #2
Hello Derek,

Thank you very much for giving me a detailed information
on creating graphics on a web form.

let me explain the issue in a detailed way.
I'm creating a web page which will display the MAP as a
JPG file. I want to create an ZOOM IN event - when the
user clicks on 'zoom in' button, he should be able to
draw a rectangle on the map. The program should also
capture the starting and ending points of the rectangle,
so that I can pass the co-ordinates to the server which
will get me the new image.

I think the best option is to throw out the windows code
all together and build a new one.

Any help would be really appreciated.

Regards
Ryan
-----Original Message-----
"Ryan" <an*******@discussions.microsoft.com> wrote in message news:09****************************@phx.gbl...
I'm trying to draw a rectangle on a web page which
contains a picture. Following is the function for a
similar windows application.

: :
When I'm building the solution its giving me an error
System.Web.UI.Webcontrols.Image doesn't contain a
definition for handle.


There are a number of fundamental differences between

Windows(rich client) graphics and Web (thin client) graphics. You prettymuch have to either (a) throw out that Windows code altogether,or (b) salvage it perhaps by using WinForms graphics code torender drawings to a Bitmap and then save off that Bitmap (asa .jpg, .gif, or other graphics file format) to some location on theweb server that clients can reach (be careful if you do save afile from your Web application that the ASPNET account hassecurity privileges granted to it sufficient enough to create theimage file on the server's file system).

If there's a dynamically generated image file on the server for theWeb Form to refer to using an IMG tag, then it's simply a matterof rendering <IMG SRC="url_of_your_graphics_file.png" /> out tothe HTTP response stream when the page renders. This still carriesthe problem of how to clean-up after such dynamically generatedfiles, though (because of ASP.NET's inherent statelessness).
Nothing in that Windows function will give you a clue about the Webenvironment. In an ASP.NET WebForms application, you muchrender HTML markup to the client's web browser -- this is all textthat describes what the page should look like. Browsers like InternetExplorer, Mozilla, and Firefox all interpret the HTML and display itto your end user (sometimes these browsers will interpret the HTMLin varied and unexpected ways! Web progamming isn't just a job,it's a neverending epic adventure ...) Usually they create peer con-trols using the end user's own operating system's rich graphics sub-system, that correspond to HTML elements that a user can interactwith. However, the exact characteristics of a button to a user onInternet Explorer / Windows XP with an Olive color scheme willdiffer from the appearance of a button to a user on Firefox /Macintosh. As a web developer, you usually don't have controlover what peer exactly the browser chooses to represent yourHTML elements as.

To draw a box in HTML, you would render this markup,

<table border="1"><tr><td> </td></tr></table>

What you could do in Visual Studio .NET is create a Web
Custom Control library (using that project type), overridethe Render method in the class file it produces for you towrite that string above to the HtmlTextWriter argument it
receives, then build this library. Next, open the Toolboxwith Control-Alt-X key, and Customize one of the tabs,
so that you can Add a .NET Framework component.
Browse until you find the .dll file that you just created,the Custom Control library, and drag and drop that
onto your WebForm1.aspx's Design View. You should
see a preview of the box at design-time, similar to what
it would look like at run-time.

Other subjects you may want to investigate for more
information are VML (Vector Markup Language) and
it's successor, SVG (Scalable Vector Graphics). VML
is obsolete but it has the benefit of being built-in to InternetExplorer 5 (but no other brands of browser). SVG is the
heir to the throne, but it still requires that you install a plugin to make your browser display SVG (Adobe offers one
free plug-in for SVG on Internet Explorer, there are also
other plug-ins out there for SVG on Mozilla and Firefox
brands of browser.) Until you have a tighter grasp of thedifferences between ASP.NET and WinForms, rushing
headlong into these specialty markup languages may be
premature though.
Derek Harmon
.

Nov 16 '05 #3
Ryan,
I don't know the answer to this, but I _do_ know that the C# newsgroup
isn't the best for handling the advanced DHTML question. I would
suggest trying a DHTML, javascript, or at least the ASP.NET newsgroup.
Sorry I couldn't be of more help.
Best regards,
Jeffrey Palermo
http://www.jeffreypalermo.com

Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
12288
by: Champika Nirosh | last post by:
Hi, I want to create drawing board application that can draw Line, rectagle, circle and free hand drawing. Each drawing need to be transparent, moveable (draggable), have bring to front and...
0
1196
by: sachin | last post by:
Please read the code snippets belo snippet 1: Drawing rectangle using Device Context...
4
12298
by: Stuart Norris | last post by:
Dear Readers, I am attempting to draw box around some text using unicode on multiline label. The label is forty characters wide and 12 lines deep. I have been trying to draw a box around text...
6
8120
by: johannblake | last post by:
I am wondering whether it is easy to setup a coordinate system for drawing (using GDI+) that uses meters (or any custom scaling for that matter). Currently, I need to convert from pixels to meters...
13
3284
by: Metallicraft | last post by:
I have a vb6 application. On the main form is a picture box with one or two images and several pieces of text displayed in it. These are created on the fly using gdi32 routines that are all in a...
1
1681
by: YYZ | last post by:
Sorry for the multipost, but no one was responding in the other thread. If any solution is forthcoming, I will return to the original thread and post it there as well. I've created a usercontrol...
3
4801
by: Ivonne Riedel | last post by:
Working on an incremental drawing algorithm I am facing a problem PInvoking ScrollWindowEx: The code is as follows... C#: public static extern int ScrollWindowEx(IntPtr hWnd, int dx, int...
4
26925
by: RobinS | last post by:
I am drawing a rectangle on a picture that has already been drawn on the graphics area (a user control). It works something like this: //in the MouseDown event m_isDragging = true; m_oldX =...
2
2310
by: ThatsIT.net.au | last post by:
I have this code that writes a pie chart in a asp.net page, but I want to use it in a server control. When I try I get a error on the last line "Response.OutputStream" Obviously there is no...
7
3537
by: raylopez99 | last post by:
I have a logical drawing space much bigger than the viewport (the screen) and I'd like to center the viewport (the screen) to be at the center of the logical drawing space. After following the...
0
7142
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7181
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6847
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
4875
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4565
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3078
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
618
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
272
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.