473,513 Members | 2,676 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Drawing in Custom Controls

Heya,

I have a cusom control:

Imports System.ComponentModel
Imports System.Web.UI
<DefaultProperty("Text"), ToolboxData("<{0}:WebCustomControl5
runat=server></{0}:WebCustomControl5>")> Public Class WebCustomControl5
Inherits System.Web.UI.WebControls.WebControl
Dim _text As String
<Bindable(True), Category("Appearance"), DefaultValue("")> Property
[Text]() As String
...
End Property
Protected Overrides Sub Render(ByVal output As
System.Web.UI.HtmlTextWriter)
output.Write([Text])
End Sub
End Class

I want to draw graphics (bmp's) in 'Render'. How is this done? In VB.NET
controls you could do things like:

Protected Overrides Sub OnPaint(ByVal e As
System.Windows.Forms.PaintEventArgs)
With e.Graphics
.DrawImage(...)
End With
End Sub

Any help/links appriciated,

mr noob.
Nov 19 '05 #1
3 1762
Hi Qwert,

SORRY this cannot be done in ASP.Net. The output of an ASPX file is HTML,
and no binary data. You can create a HttpHandler which creates an image on
the fly and than reference to it with a System.Web.UI.WebControls.Image or a
simple <img>-Tag.

e.g. <img src="MyImageCreator.ashx" />

this article could help:
http://weblogs.asp.net/cazzu/archive.../27/25568.aspx

"Qwert" wrote:
Heya,

I have a cusom control:

Imports System.ComponentModel
Imports System.Web.UI
<DefaultProperty("Text"), ToolboxData("<{0}:WebCustomControl5
runat=server></{0}:WebCustomControl5>")> Public Class WebCustomControl5
Inherits System.Web.UI.WebControls.WebControl
Dim _text As String
<Bindable(True), Category("Appearance"), DefaultValue("")> Property
[Text]() As String
...
End Property
Protected Overrides Sub Render(ByVal output As
System.Web.UI.HtmlTextWriter)
output.Write([Text])
End Sub
End Class

I want to draw graphics (bmp's) in 'Render'. How is this done? In VB.NET
controls you could do things like:

Protected Overrides Sub OnPaint(ByVal e As
System.Windows.Forms.PaintEventArgs)
With e.Graphics
.DrawImage(...)
End With
End Sub

Any help/links appriciated,

mr noob.

Nov 19 '05 #2
Thanks. I now draw everything and then send the result with <img> tag
indeed.
"Patrick" <Pa*****@discussions.microsoft.com> schreef in bericht
news:99**********************************@microsof t.com...
Hi Qwert,

SORRY this cannot be done in ASP.Net. The output of an ASPX file is HTML,
and no binary data. You can create a HttpHandler which creates an image on
the fly and than reference to it with a System.Web.UI.WebControls.Image or
a
simple <img>-Tag.

e.g. <img src="MyImageCreator.ashx" />

this article could help:
http://weblogs.asp.net/cazzu/archive.../27/25568.aspx

"Qwert" wrote:
Heya,

I have a cusom control:

Imports System.ComponentModel
Imports System.Web.UI
<DefaultProperty("Text"), ToolboxData("<{0}:WebCustomControl5
runat=server></{0}:WebCustomControl5>")> Public Class WebCustomControl5
Inherits System.Web.UI.WebControls.WebControl
Dim _text As String
<Bindable(True), Category("Appearance"), DefaultValue("")> Property
[Text]() As String
...
End Property
Protected Overrides Sub Render(ByVal output As
System.Web.UI.HtmlTextWriter)
output.Write([Text])
End Sub
End Class

I want to draw graphics (bmp's) in 'Render'. How is this done? In VB.NET
controls you could do things like:

Protected Overrides Sub OnPaint(ByVal e As
System.Windows.Forms.PaintEventArgs)
With e.Graphics
.DrawImage(...)
End With
End Sub

Any help/links appriciated,

mr noob.

Nov 19 '05 #3
Hi mr. noob,

You might want to put down that custom control for a bit, and familiarize
yourself with your UI. It's a web page. If you're not familair with web
pages and HTML, you're going to have beaucoups trouble. Why? Because a web
page is not a VB6 executable sitting on your machine. It is a TEXT document.
Next time you're using your browser, view the souce code for the page.
First, make sure there are images in it, so you can see this for yourself.
Note that the TEXT document that is the HTML page has no images in it. Of
course, how could it? Its a text document.

So, where do the images come from, and how do they get into the browser, in
the right places in the document? It is via an image tag in the markup.
Example:

<img src="/images/someimage.jpg">

Now, as the browser is displaying an HTML document, where does the image
come from? It is downloaded from the specified URL in the image tag and
rendered in the browser BY the browser.

So, how do you draw in an ASP.Net page? The answer is, you don't. You draw
an image on the server, and stream it to the browser when requested.

How is this done in an ASPX page? Well, you need to create another ASPX page
that serves as the "image." When this page is requested, it draws an image
on the server side, sets the Response.ContentType to "image/jpg" (the
correct MIME type for that image type), and saves the image to the
Response.OutputStream. The browser, which ordinarily derives what type of
file it is receiving from the file extension, will instead read the
ContentType header, and display the binary output as an image.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"Qwert" <no**@nosp.com> wrote in message
news:1b********************@casema.nl...
Heya,

I have a cusom control:

Imports System.ComponentModel
Imports System.Web.UI
<DefaultProperty("Text"), ToolboxData("<{0}:WebCustomControl5
runat=server></{0}:WebCustomControl5>")> Public Class WebCustomControl5
Inherits System.Web.UI.WebControls.WebControl
Dim _text As String
<Bindable(True), Category("Appearance"), DefaultValue("")> Property
[Text]() As String
...
End Property
Protected Overrides Sub Render(ByVal output As
System.Web.UI.HtmlTextWriter)
output.Write([Text])
End Sub
End Class

I want to draw graphics (bmp's) in 'Render'. How is this done? In VB.NET
controls you could do things like:

Protected Overrides Sub OnPaint(ByVal e As
System.Windows.Forms.PaintEventArgs)
With e.Graphics
.DrawImage(...)
End With
End Sub

Any help/links appriciated,

mr noob.

Nov 19 '05 #4

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

Similar topics

0
1263
by: Hakan Andersson | last post by:
Hi! I'm a system designer/programmer starting up a new project where we want to be able to let the end user create graphic pictures. The application will be web-based using C#. The...
1
1905
by: David Whitchurch-Bennett | last post by:
Hi there, I am writing an custom designer, and need a rubber band to select controls. I am drawing the rubber band by using the Graphics object on the user control where the other controls sit...
0
881
by: JimBob | last post by:
I want to make a PowerPoint kinda app. I am by no means an expert at VB.NET but learn quickly and need some direction. what i want to do is get a picture path from xml and then paint the picture...
9
3160
by: davetelling | last post by:
I am not a programmer, I'm an engineer trying to make an interface to a product I'm designing. I have used C# to make a form that interrogates the unit via the serial port and receives the data. I...
3
8437
by: kamleshgk | last post by:
Hi, I have a requirement to draw a rectangle and a line on a the container control and sometimes as i move the mouse the drawing must occur on top of user controls and other controls, which are...
0
1103
by: neo | last post by:
I am working on vs2k5. I made MFC-SDI application and view class inherited from CListView. I was tried a lot to bold one row in List using custom drawing but I was able not understand, how to use...
15
6477
by: rizwanahmed24 | last post by:
Hello i have made a custom control. i have placed a panel on it. I want this panel to behave just like the normal panel. The problem i was having is that the panel on my custom control doesnt...
6
7708
by: =?Utf-8?B?bGpsZXZlbmQy?= | last post by:
I am implementing an Office 2007 – like interface, including the ability to change colors. One issue that I have is that scrollbars look poor if the application color theme (e.g., Black) does...
2
2312
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...
1
424
by: Jeff Johnson | last post by:
"Nathan Sokalski" <njsokalski@hotmail.comwrote in message news:er%23hyAFOJHA.1896@TK2MSFTNGP02.phx.gbl... Since this is derived from a Web class, I can't really help much, being a desktop guy,...
0
7158
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7535
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
7098
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...
0
7523
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5683
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4745
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
3232
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
1592
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.