473,763 Members | 1,382 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.Componen tModel
Imports System.Web.UI
<DefaultPropert y("Text"), ToolboxData("<{ 0}:WebCustomCon trol5
runat=server></{0}:WebCustomCo ntrol5>")> Public Class WebCustomContro l5
Inherits System.Web.UI.W ebControls.WebC ontrol
Dim _text As String
<Bindable(True) , Category("Appea rance"), DefaultValue("" )> Property
[Text]() As String
...
End Property
Protected Overrides Sub Render(ByVal output As
System.Web.UI.H tmlTextWriter)
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.PaintEven tArgs)
With e.Graphics
.DrawImage(...)
End With
End Sub

Any help/links appriciated,

mr noob.
Nov 19 '05 #1
3 1777
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.W ebControls.Imag e or a
simple <img>-Tag.

e.g. <img src="MyImageCre ator.ashx" />

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

"Qwert" wrote:
Heya,

I have a cusom control:

Imports System.Componen tModel
Imports System.Web.UI
<DefaultPropert y("Text"), ToolboxData("<{ 0}:WebCustomCon trol5
runat=server></{0}:WebCustomCo ntrol5>")> Public Class WebCustomContro l5
Inherits System.Web.UI.W ebControls.WebC ontrol
Dim _text As String
<Bindable(True) , Category("Appea rance"), DefaultValue("" )> Property
[Text]() As String
...
End Property
Protected Overrides Sub Render(ByVal output As
System.Web.UI.H tmlTextWriter)
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.PaintEven tArgs)
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*****@discus sions.microsoft .com> schreef in bericht
news:99******** *************** ***********@mic rosoft.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.W ebControls.Imag e or
a
simple <img>-Tag.

e.g. <img src="MyImageCre ator.ashx" />

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

"Qwert" wrote:
Heya,

I have a cusom control:

Imports System.Componen tModel
Imports System.Web.UI
<DefaultPropert y("Text"), ToolboxData("<{ 0}:WebCustomCon trol5
runat=server></{0}:WebCustomCo ntrol5>")> Public Class WebCustomContro l5
Inherits System.Web.UI.W ebControls.WebC ontrol
Dim _text As String
<Bindable(True) , Category("Appea rance"), DefaultValue("" )> Property
[Text]() As String
...
End Property
Protected Overrides Sub Render(ByVal output As
System.Web.UI.H tmlTextWriter)
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.PaintEven tArgs)
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.Conten tType to "image/jpg" (the
correct MIME type for that image type), and saves the image to the
Response.Output Stream. 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.co m> wrote in message
news:1b******** ************@ca sema.nl...
Heya,

I have a cusom control:

Imports System.Componen tModel
Imports System.Web.UI
<DefaultPropert y("Text"), ToolboxData("<{ 0}:WebCustomCon trol5
runat=server></{0}:WebCustomCo ntrol5>")> Public Class WebCustomContro l5
Inherits System.Web.UI.W ebControls.WebC ontrol
Dim _text As String
<Bindable(True) , Category("Appea rance"), DefaultValue("" )> Property
[Text]() As String
...
End Property
Protected Overrides Sub Render(ByVal output As
System.Web.UI.H tmlTextWriter)
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.PaintEven tArgs)
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
1274
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 drawing-area need to have a bitmap as a background and on that bitmap, the user should be able to put/create approx. 10 different custom-made objects. Objects should not be resized. Some should be possible to rotate and some not. Custom lines with arrows on...
1
1918
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 (hope that makes sense). The rectangle object that I draw on the user control appears behind the other child controls. Is there a way to force the graphics object to be painted on top of the other controls?
0
890
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 on my form, then add some custom controls on top of the picture and get there properties i.e. placement, size and text, from the xml script. When the user clicks next to see the next slide i want to do it all over again with a different pic and...
9
3181
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 want to be able to draw lines in a picturebox based upon certain data points I have received. I dragged a picturebox from the toolbar onto my form, but after having gone through the help files, looking online and trying a variety of things, I...
3
8454
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 placed in the container control... I'm using System.Drawing namespace (C#) to perform the drawing. But as i move the mouse and draw the rectangles, the drawing takes place behind the user controls....I have a requirement to
0
1119
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 custom drawing. I was changed text color of one row using custom drawing, and following code written for NM_CUSTOMDRAW message void CTestView::OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *pResult) {
15
6521
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 accept other controls. The control i drag drop on it becomes the child of my custom control's parent form and not the child of my custom control. Then i added this line "" before my custom control class (i dont know what this line does). Now
6
7723
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 not match the windows color theme (e.g., Blue). So, I want to custom draw every scrollbar within my application. The problem is that scrollbars can show up in many types of controls that I use within my app, such as in Forms, TextBoxes, ComboBox...
2
2329
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 response object but how do I write it to screen? Dim objBitmap As New System.Drawing.Bitmap(400, 440) Dim objGraphics As System.Drawing.Graphics objGraphics = System.Drawing.Graphics.FromImage(objBitmap) objGraphics.Clear(Drawing.Color.White)
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, but I have to wonder: why WriteOnly?
0
9563
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9386
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9998
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9822
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5270
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5406
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3917
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 we have to send another system
3
3523
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2793
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.