473,837 Members | 1,889 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem to create web control using graphics

Hi All,

I want some charting functionality in my ASP.NET application.

I want to show a multiple bar on my web page. It's based on down time
of different servers.
server1: down betn 4 AM to 5 AM and 6 PM to 7 PM
server2: down betn 7 AM to 7:30 AM
server3: down betn 3 AM to 5 AM and 2 Pm to 3 PM
and so on....

Now, all total number of server is in database and i want to display
server down chart in just besides of this server on my summary page.

Now problem is, this page is dynamic and my chart for server may
contain differnt color and different segments.

So for that, I want to create a custom control/User control so i can
avoid the repeatative programing.

Now i want to use graphics for this in my control. and it's working
fine for asigning that aspx page from my image src="" attribute.

but this is stateless, and i can only pass different parameter in
querysting like...
img1.ImageUrl = "BarChart.aspx? startTime=" + t1 + "&endTime=" + t2;

but instead of query string i want to store it in either session or
viewState to use it in my BarChart.aspx page. But it's not working. any
idea what would be the problem.

Below is my code, i have two file one is BarChart.aspx and
Server_down_tes ting.aspx.
I m only uploading the codebehind.

See the below code is working fine, but this is not robust and every
time i have to pass starttime and endtime in query string, instead of
that i want to pass this as array in the session or viewstate.

i tried it by simply session/viewstate but every time it's not
generating the new image, it's taking the first one...

also if we can create user control/custom control then it's good for

Thanks & Regards

///////////////***** BarChart.aspx *************** ****//////////////

<%@ Page Language="C#" debug="true"%>
<%@ Import Namespace="Syst em.Drawing" %>
<%@ Import Namespace="Syst em.Drawing.Imag ing" %>

<script language="C#" runat="server">

void Page_Load(Objec t sender, EventArgs e)
Single width, height;
width = 800;
height = 30;
int maxSegment = 24;

string color;
int start, end;

Bitmap objBitmap = new Bitmap(width, height);

Graphics objGraphic = Graphics.FromIm age(objBitmap);

start = Convert.ToSingl e(Request["startTime"]);
end = Convert.ToSingl e(Request["endTime"]);
SolidBrush colorBrush = new SolidBrush(Colo r.Red);

Pen blackPen = new Pen(Color.Black , 2);

objGraphic.Fill Rectangle(white Brush, 0, 0, width, height);

Single newPos, newWidth;
newPos = (width / maxSegment) * start;
newWidth = (width / maxSegment) * (start - end);

objGraphic.Fill Rectangle(color Brush, newPos, 0, newWidth,
Response.Write( newPos.ToString () + " : " +
newWidth.ToStri ng());
Response.Conten tType = "image/gif";

objBitmap.Save( Response.Output Stream, ImageFormat.Gif );



///*************** * Server_down_tes ting.aspx
*************** *******/////

<%@ Page Language="C#" AutoEventWireup ="true"
CodeFile="calen darTest.aspx.cs " Inherits="calen darTest" %>
<%@ Import Namespace="Syst em.Drawing" %>
<%@ Import Namespace="Syst em.Drawing.Imag ing" %>
<script language="C#" runat="server">

void Page_Load(Objec t sender, EventArgs e)
for (int i = 1; i <= 10; )
System.Web.UI.W ebControls.Imag e img1 = new
System.Web.UI.W ebControls.Imag e();
img1.ID = "img-" + i;

v1= 2 * i;
v2= 4 * i;
v3= 5 * i;
// Session["v1"] = v1;
// Session["v2"] = v2;
// Session["v3"] = v3;

//img1.ImageUrl = "BarChart_CShar p1.aspx";
img1.ImageUrl = "BarChart.aspx? startTime=" + v1 + "&endTime=" +
Panel1.Controls .Add(img1);
i += 1;



<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitl ed Page</title>
<form id="form1" runat="server">
<asp:Panel ID="Panel1" runat="server" Height="50px"

Thanks & Regards,

Mar 29 '06 #1
1 2356

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

Similar topics

by: Billy Jacobs | last post by:
I have created a DataGridColumnDatePicker Component so that I can put a datetimepicker control in my datagrid. It almost works. When I put my mouse in the cell it changes to a datetimepicker control. I can then select a date which displays in the cell. When I leave the cell however I get the following error:
by: Abhishek | last post by:
My objective is quite simple. I want to display a JPG image and then on it overlay a polygon. This polygon can be moved by a user. The even is trapped on the mouse down event of the control. I can make the polygon move but the screen flickers because I call invalidate() on the mouse down event. I did do offscreen buffering but there is still flashing in the screen. Let me explain what I am doing. in the pain even handler of the control I...
by: Sagaert Johan | last post by:
I have made a custom control that draws a rectangle when the mouse is down, and does nothing when the mouse is up. I set/reset a flag in MouseDown/Mouse up and use this to do the drawing in the OnPaint . The recangle draws correct when i press the mouse, but when i release the mouse the background is not restored What should i do in the Onpaint to make sure the background (the form) is restored correctly ? This problem already keeps...
by: steve bull | last post by:
I have created a UserControl and added it to my toolbox. It appears in the toolbox with the icon I created for it. The problem is that when I drag the control onto a form no code is generated. If I manually add the code for creating the control to the form everything works fine. I have created other controls w/o problems and cannot see anything I am doing different in this case. Does anyone have any idea what I could be doing wrong? ...
by: steve bull | last post by:
When adding a new user control to a panel I get the following call stack. Having put debugs everywhere I can think of I cannot get the program to break anywhere near where it is having this problem. System.ArgumentException: Invalid parameter used at System.Drawing.Graphics.EndContainer(GraphicsContainer container) at System.Windows.Forms.DibGraphicsBufferManager.ReleaseBuffer(GraphicsBuffer buffer) at...
by: news | last post by:
This may be a stupid question, but if I don't ask I'll never know ;) Ok, here it goes.... I am writing an application that renders an image in one picturebox and a graph in another. The image is drawn by loading a jpg into a bitmap and then setting picturebox.image = mybitmap. Ive created my own class, inheriting from the picturebox and overriding the OnPaint event so I can do e.Graphics.DrawImage (this.image....). This renders...
by: Carl Heller | last post by:
Working in VS2003, .Net 1.1 I'm working on a project where I compare data between two databases. This is a lengthy process, and very data intensive, so I decided to create a class, and thread out the work. The order of work is as follows: 1. Retrieve the data from primary data source 2. Update UI with retrieved data - this is accomplished by passing a dataset as an event parameter
by: Mark B | last post by:
I want to display a pre-designed graphical 'performance badge' on certain webpages (round, about 2cm diameter) next to a salesperson's details. I have a function, fGetPerformanceGrade(SalesPersonID as Long) as String to retrieve that salesperson's grade (e.g. A+, A, A-, B+, B... D). Also one other function, fGetMonthlySales(SalesPersonID as Long) as String to get their sales figure, e.g. "$87K". I want web visitors to be able to click...
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...
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
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...
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
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...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
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.