473,386 Members | 1,973 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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.
like
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_testing.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
me.

Thanks & Regards
Rushikesh

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

<%@ Page Language="C#" debug="true"%>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Imaging" %>

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

void Page_Load(Object 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.FromImage(objBitmap);

start = Convert.ToSingle(Request["startTime"]);
end = Convert.ToSingle(Request["endTime"]);
SolidBrush colorBrush = new SolidBrush(Color.Red);

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

objGraphic.FillRectangle(whiteBrush, 0, 0, width, height);

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

objGraphic.FillRectangle(colorBrush, newPos, 0, newWidth,
height);
Response.Write(newPos.ToString() + " : " +
newWidth.ToString());
Response.ContentType = "image/gif";

objBitmap.Save(Response.OutputStream, ImageFormat.Gif);

}

</script>

///**************** Server_down_testing.aspx
**********************/////

<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="calendarTest.aspx.cs" Inherits="calendarTest" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<script language="C#" runat="server">

void Page_Load(Object sender, EventArgs e)
{
for (int i = 1; i <= 10; )
{
System.Web.UI.WebControls.Image img1 = new
System.Web.UI.WebControls.Image();
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_CSharp1.aspx";
img1.ImageUrl = "BarChart.aspx?startTime=" + v1 + "&endTime=" +
v2;
Panel1.Controls.Add(img1);
i += 1;
}

}

</script>

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

</asp:Panel>
</div>
</form>
</body>
</html>
Thanks & Regards,
Rushikesh

Mar 29 '06 #1
1 2333

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

Similar topics

3
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...
2
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...
11
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...
4
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...
5
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....
7
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...
2
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...
11
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,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...

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.