You could create an aspx page that generates the image and then use the url of that page for the src of the image in the button.
e.g. your image button declaration would be:
<asp:ImageButton ID="ImageButton1" src="image.aspx" runat="server" />
Then add a webform called image.aspx and replace the whole html source with...
<%@ Page ContentType = "image/gif"%>
<%@ Import Namespace = "System.Drawing" %>
<%@ Import Namespace = "System.Drawing.Imaging" %>
<%@ Import Namespace = "System.IO" %>
<Script Runat = "Server">
Sub Page_Load()
Dim objBitmap As Bitmap
Dim objGraphics As Graphics
objBitmap = New Bitmap(100, 100)
objGraphics = Graphics.FromImage(objBitm
objGraphics.DrawLine(New Pen(Color.Red), 0, 0, 100, 100)
Dim oBrush As New SolidBrush(Color.Green)
objGraphics.DrawString("Te
Dim io As MemoryStream = New MemoryStream()
objBitmap.Save(io, ImageFormat.Png)
Response.BinaryWrite(io.Ge
objBitmap.Dispose()
objGraphics.Dispose()
Response.End()
End Sub
</Script>
This will generate a png file on the fly with a diagonal red line and some green text.
Then if you want to use an existing image, you could load it into the bitmap object first, then write you text on top of it. So you can leave the image on half of it and draw on the other half.
Regards,
Psyberion.
Main Topics
Browse All Topics





by: needo_jeePosted on 2009-11-05 at 16:15:36ID: 25755580
What sketch I have in mind, is creating a image with text and then embedding it with exiting image... so that it makes a complete image having icon part as well as text.
The reason for doing so is, its difficult to align and format text on buttons.. the text and images will keep changing frequently. so it would be good to create an image and then set as button image.
-thanks