Print
Add To Favorites
Email To Friend
Rate This Article
|
Building a Page Counter (Image) Using JScript.Net
|
by Devarticles.com
Feedback
|
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days):
28653/
62
|
|
|
The JScript.Net Code, Part 2 |
Now we want to replace the text counter with an image that we will create on the fly. Add the following code to counter.aspx before the "Response.Write(getCounter());" line:
[code="JScript"]
function drawCounter() { var height:int=20; var width:int=60;
var bmp:Bitmap = new Bitmap(width, height); var img:Graphics = Graphics.FromImage(bmp);
var white:SolidBrush = new SolidBrush(Color.White); var black:SolidBrush = new SolidBrush(Color.Black);
var CurrentCounter:String = getCounter();
var CounterFont:Font = new Font("Arial", 8, FontStyle.Bold); var Text:SizeF = img.MeasureString(CurrentCounter,CounterFont);
img.FillRectangle(black, 0, 0, width, height); img.DrawString(CurrentCounter, CounterFont, white ,(bmp.Width)-((Text.Width)+5),3);
bmp.Save(Response.OutputStream, ImageFormat.Jpeg);
img.Dispose(); bmp.Dispose(); } |
[/code] |
|
|
User Comments
Title:
Firefox :s
Name:
Remi
Date:
2007-04-07 9:04:44 AM
Comment:
Thnx! Works great in IE! Only Firefox has some problems displaying the image. It just shows a range of weird characters :s.
|
Title:
SPA
Name:
dheeraj Ahuja
Date:
2005-10-28 3:07:28 AM
Comment:
this is gud article and it helped me alot now wht i want is to call a server side from client routine with refering any "src", is there any way
|
|
Product Spotlight
|
|