473,594 Members | 2,768 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.
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_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
me.

Thanks & Regards
Rushikesh

///////////////***** 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,
height);
Response.Write( newPos.ToString () + " : " +
newWidth.ToStri ng());
Response.Conten tType = "image/gif";

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

}

</script>

///*************** * 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=" +
v2;
Panel1.Controls .Add(img1);
i += 1;
}

}

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitl ed 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 2341

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

Similar topics

3
2028
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:
2
2199
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...
11
6177
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...
4
2141
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? ...
5
5252
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...
7
3219
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...
2
2589
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
11
5353
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...
0
7936
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
7874
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
8241
Oralloy
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...
0
8366
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
8227
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...
1
5738
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3853
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
3893
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1203
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.