Category Archives: Chart

[RESOLVED] How to trigger certain methods on different aspx page using usercontrol



I have got 3 aspx page and a usercontrol on each page have an email placeholder in it. What I want to acheive is when the customer 

click on the usercontrol email placeholder, certain method on a particular page should trigger. See below for the code:

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ucBottomMenu.ascx.cs"
    Inherits="uc_ucBottomMenu" %>
<div id="dockWrapper" style="position: fixed; background: url('../images/bg-50percent.png');
    padding: 10px; margin: 0 auto; width: 700px; height: 100px;" class="noprint">
    <div id="dock">
   	    <asp:PlaceHolder ID="phEmail" runat="server"><a id="hplEmail" runat="server">
            <img src="../images/dock/email.png" title="Email" alt="Email" /></a> </asp:PlaceHolder>

//aspx page.. I want to trigger this method when the email button is clicked, this method generated pdf

 protected void CreateSummaryPDF(object sender, EventArgs e)
        // create all node chart images
          //==========Difficult Situation Chart============//
        IDataReader dr1 = null;
         dr1 = LBM.ChartGetSlider(userID, LBM.Slider.DifficultSituations);
         Points obj1 = SortToYArray(dr1);
        ChartDifficultSituations.SaveImage(Server.MapPath("../images/charts/") + SessionID.ToString() + "_" + LBM.Node.DifficultSituations.ToString() + ".png", ChartImageFormat.Png);
        double a = obj1.maxVal;

        double[] check = { a };
        // set up pdf
        IPdfManager objPdf = new PdfManager();

        // Create empty document
        IPdfDocument objDoc = objPdf.OpenDocument(Server.MapPath("../client/pdf/Progress-summary.pdf"), Missing.Value);
        IPdfPage objPage = objDoc.Pages[1];
        IPdfFont objFont = objDoc.Fonts["Helvetica-Bold", Missing.Value];

        int[] arrX = { 80, 306, 80, 306, 80, 306, 80, 306 };
        int[] arrY = { 590, 590, 290, 290, 590, 590, 290, 290 };


        int i = 0;

        // loop nodes and place on PDF
        foreach (string name in Enum.GetNames(typeof(LBM.Node)))

            // move onto the next page
            if (i > 3) {
                objPage = objDoc.Pages[2];

            // add images
            IPdfImage objImage = objDoc.OpenImage(Server.MapPath("../images/charts/") + SessionID.ToString() + "_" + name + ".png", Missing.Value);
            // Add empty page. Page size is based on resolution and size of image
            float fWidth = objImage.Width * 72.0f / objImage.ResolutionX;
            float fHeight = objImage.Height * 72.0f / objImage.ResolutionY;

            // Create empty param object
            IPdfParam objParam = objPdf.CreateParam(Missing.Value);

            objParam["x"].Value = arrX[i];
            objParam["y"].Value = arrY[i] - fHeight;

            objPage.Canvas.DrawImage(objImage, objParam);
            objPage.Canvas.DrawText(name, "x=" + arrX[i] + ", y=" + (arrY[i]+50) + "; width=208; height=200; size=11; alignment=center; color=#ffffff", objFont);



        String strFileName = objDoc.Save(Server.MapPath("../client/pdf/filledform.pdf"), true);


Also I have got another method on a different aspx page, I want to trigger that method when the client is on that page. The user control
should trigger the right method depending on the page user is currently on.

Custom event in the user control.  The idea is that the user control will trigger the event when user clicks on email placeholder.  The conrtainer pages (the aspx pages) will subscribe to this event, so when the event is triggered the page can then do whatever it needs, including calling any method you might want.

Any quick example of it plz

No, but I'm very good at Boogling.

You can try: (rather simplified) or (rather detailed/complex) or

I don't know if these links are good; just glanced through them briefly.

Yeh , I have figured out , forgot to post it , What I have is similar to examples which you mentioned above,


 public Action<object, EventArgs> MyEvent;

//And in the page Load

 public void Page_Load(object sender, EventArgs e)
        //hplEmail is the placeholder which cant be use for onclick event
       // therefore I have used Server click
        hplEmail.ServerClick += new EventHandler(check);

 public void check(object sender, EventArgs e)

       MyEvent(sender, e);

//aspx pages
//just call that event

 protected void Page_Load(object sender, EventArgs e)
        this.ucBottomMenu1.MyEvent = CreateDiaryPDF; //CreateDiaryPDF is the method where pdf is created and emailed...


[RESOLVED] Using Delegate in user control to trigger events



I have got a query regarding the usage of delegate in usercontrols. The scenario is I have got a user control which acts as a footer

on all the pages, It has the following place holders : Email, Print, Logout.

What I want to acheive here is when the customer logged in he/she has certain feauture's on the website for instance his/her personal diary,

dieting charts, birthday calender etc. I have figured out a way to create pdf's of each summary , what I am looking for is how to use the usercontrol

for instance when the customer clicks on the email place holder on certain page which is in the footer usercontrol, the following place holder should send

an email with the pdf file of that particular page attached to the customer. I came to know that delegate is the best way of doing it, but I cant

find any specific tutorial on it.


Any help or tutorial on it , will be appreciated.


You could also just expose the click even handlers of your placeholders on the user control for the containg page to hook and react to appropriately.

Do you really need custom delegates? Wouldn't it be simpler to have the links at the bottom of the page do a postback to the code that sends the mail? Just use a LinkButton.

Cant just use linkbuttons, coz I need to trigger methods on aspx pages using a fixed usercontrol in the footer, I have figured out by using event handler,


Thnx for the replies.

[RESOLVED] Trim comma from end of string

I'm trying to trim a comma from the end of a string.


I've tried the following:



I've also tried:

char[] CharToTrim = { ',' };



Neither option is working, any ideas???

are there possibly some spaces also at the end of that string after the comma?

try trimming spaces as well

There's no space


The string is 10,15,


I need to remove the comma from the end.

The trim methods return a new string.

make sure to assign the results to your variable

Variable = Variable.TrimEnd(CharToTrim);



I know this probably seemed like a pretty stupid question, but I've been banging my head against the wall on this one. 

[RESOLVED] ASP:CHART control with multiple y values

I need to draw a chart with two colums to each x value.

I wll be very happy if someone has an example for this.

I try to binds chart series two field to the Y axis with DataBind and Point.AddXY but it's not working for me.

I got exeption like:

Data points insertion error. Only 1 Y values can be set for this data series


Series data points do not support values of type System.Int32[] only values of these types can be used: Double, Decimal, Single, int, long, uint, ulong, String, DateTime, short, ushort.



I think if this question posted in bottom forums, then it will be answered quickly -