Response.Redirect cannot be called in a page callback error message.

Last post 06-30-2008 9:35 AM by andymc33. 10 replies.

Sort Posts:

  • Response.Redirect cannot be called in a page callback error message.

    10-04-2007, 5:16 PM
    • Member
      13 point Member
    • jen_bonnett
    • Member since 09-08-2006, 9:58 PM
    • Posts 46

    Hi.  I'm using the Dundas Chart Controls in VS 2005.  These controls are built utilizing AJAX.  I have a basic page with a dundas chart control containing a funnel chart.  The funnel contains Quotes, Sales Orders and Invoices.  When the user clicks on the control, I want to determine whether they clicked on Quotes, Sales Orders or Invoices and transfer to the appropriate Details Page.  I've got the code working to determine which transaction type they clicked on; but, I get the "Response.Redirect cannot be called in a page callback." error when the page tries to redirect.  Note: I get a similar issue if I try server.transfer.

    Suggestions?

     Here's my code:

    Dim hitTestResult As Dundas.Charting.WebControl.HitTestResult = Chart1.HitTest(e.X, e.Y)
    
                If Not (hitTestResult Is Nothing) Then
    
                    Dim clicked As Dundas.Charting.WebControl.DataPoint = hitTestResult.Series.Points(hitTestResult.PointIndex)
    
                    Select Case hitTestResult.PointIndex
                        Case 0
    
                            Response.Redirect("COQuotes.aspx")
                        Case 1
                            Response.Redirect("COOrders.aspx")
                        Case 2
                            Response.Redirect("COOrders.aspx")
    
                    End Select
    
    
                End If
  • Re: Response.Redirect cannot be called in a page callback error message.

    10-04-2007, 6:36 PM
    Answer
    • Star
      8,978 point Star
    • dwhite
    • Member since 02-08-2007, 2:25 PM
    • Bristol, CT
    • Posts 1,422

    Since it's a partial postback that is occuring, you can't use Response.Redirect.  You need to do a full postback in order to redirect or use a different method. See the last message in this post: http://forums.asp.net/t/1165851.aspx

    -Damien

     

    Visoft, Inc - Home | Blogs

    Latest Blog Post: Silverlight DataBinding Bug
  • Re: Response.Redirect cannot be called in a page callback error message.

    10-05-2007, 11:43 AM
    • Member
      13 point Member
    • jen_bonnett
    • Member since 09-08-2006, 9:58 PM
    • Posts 46

    I have no control over the callback.  It is being executed by the Dundas Control.  I tried implementing the code with the RegisterClientScript, as below.  But, nothing happens...

     

    Dim hitTestResult As Dundas.Charting.WebControl.HitTestResult = Chart1.HitTest(e.X, e.Y)
    
                If Not (hitTestResult Is Nothing) Then
    
                    Dim clicked As Dundas.Charting.WebControl.DataPoint = hitTestResult.Series.Points(hitTestResult.PointIndex)
    
                    Select Case hitTestResult.PointIndex
                        Case 0
                            clientRedirect("COQuotes.aspx")
                        Case 1
                            clientRedirect("COOrders.aspx")
                        Case 2
                            clientRedirect("COOrders.aspx")
    
                    End Select
    
    Sub clientRedirect(ByVal URL)
            Dim jScript As String
    
            jScript = String.Format("document.location.href = '{0}');", URL)
            ClientScript.RegisterClientScriptBlock(Page.GetType(), "redirect", jScript, True)
       
        End Sub
      

     

  • Re: Response.Redirect cannot be called in a page callback error message.

    10-05-2007, 12:03 PM
    • Star
      8,978 point Star
    • dwhite
    • Member since 02-08-2007, 2:25 PM
    • Bristol, CT
    • Posts 1,422
  • Re: Response.Redirect cannot be called in a page callback error message.

    10-05-2007, 12:29 PM
    • Member
      13 point Member
    • jen_bonnett
    • Member since 09-08-2006, 9:58 PM
    • Posts 46

    Tried RegisterStartupScript, still nothing happens.

     

    Jennifer

  • Re: Response.Redirect cannot be called in a page callback error message.

    10-05-2007, 1:18 PM
    Answer
    • Member
      310 point Member
    • dj_sdix
    • Member since 06-20-2006, 4:30 PM
    • Lake District, England
    • Posts 78

    Hi,

    I'm not familiar with dundas chart but is there no way to setup a href on a chart element during rendering? I would have thought this would be a standard feature.

    Back to your Response.Redirect problem. When you get a response from the callback can you control the client-side callback function? If so you could use the cookie method as in the last post. If you have no control over the client-side callback function I  very much doubt your going to be able to add the functionality you require.

    One minor point, if your re-directing anyway whay do you need to use ajax, you could do a page post back when clicking the chart, do your logic and then redirect. To the user the behavior would seem exactly the same as your moving to a different page anyway.

    Cheers Si

  • Re: Response.Redirect cannot be called in a page callback error message.

    10-05-2007, 1:24 PM
    Answer
    • Contributor
      5,280 point Contributor
    • mrmercury
    • Member since 04-04-2006, 6:26 PM
    • Mexico City, Mexico
    • Posts 768
    You won’t be able to use Response.Redirect() or Server.Transfer() in a callback, check if the control has a client event you can use instead, if that event exists you could use window.location.replace("OtherPage.aspx"); using JavaScript from the client to move to another page.
    If this post helped you please remember to set it as Answer so it can help others.
  • Re: Response.Redirect cannot be called in a page callback error message.

    01-08-2008, 10:21 AM
    • Member
      2 point Member
    • markslade24
    • Member since 01-08-2008, 3:17 PM
    • Posts 1
    When you setup the chart set the RenderType to 'InputTag' this causes the chart to do a full postback and hence Response.Redirect shoud work (if the Chart is inside an update panel you will need to register the Click event of the chart and a postback trigger in the update panel)

    objChart.RenderType = Dundas.Charting.WebControl.RenderType.InputTag

     

  • Re: Response.Redirect cannot be called in a page callback error message.

    03-07-2008, 9:54 AM
    • Member
      29 point Member
    • phsika
    • Member since 02-03-2008, 8:22 AM
    • turkey
    • Posts 28

    Hi; i want to create a graph that's related to dundas charting. Firstly i am from Turkey; and your Question's interested me so i like to ask this Question: My chart describes wage distribution on months(jun,jully,agust etc) if i click, i want to direct jully.aspx like this. But Clicking is not working properly. For exmp; i want to see clicking cord. Textbox1.Text=e.X .tostring(),Textbox2.Text=e.Y.tostring()  and also direction is sick(jully.aspx). Would you like me help with my problems?

    Codes:

     

    using Dundas.Charting.WebControl;

    using System.Drawing.Drawing2D;

    public partial class _Default : System.Web.UI.Page

    {

    DataPoint clicked;

    protected void Page_Load(object sender, EventArgs e)

    {


    Chart1.Series["haziran"].Points.AddXY(2, 3);

    Chart1.Series["temmuz"].Points.AddXY(1, 2);

    Chart1.Series["agustos"].Points.AddXY(4, 5);


    }

    protected void Chart1_Click(object sender, ImageClickEventArgs e)

    {

    clicked = new DataPoint();

    HitTestResult hittestresult = Chart1.HitTest(e.X, e.Y);

    TextBox1.Text = e.X.ToString();

    TextBox2.Text = e.Y.ToString();

    if (hittestresult == null)

    {

    clicked = hittestresult.Series.Points[hittestresult.PointIndex];

    switch (hittestresult.PointIndex)

    {

    case 84:

    {

    Response.Redirect("haziran.aspx");

    break;

    }

    }

    }

     

    }

      

    www.ykaratoprak.blogspot.com
  • Re: Response.Redirect cannot be called in a page callback error message.

    05-20-2008, 4:19 AM
    • Member
      2 point Member
    • jmoelands
    • Member since 05-20-2008, 8:18 AM
    • Netherlands, Utrecht
    • Posts 1

    Hey All,

     This is Strange, because when you use the AJAX frameWork, you don't have control over the PostBack Situations....

    In My Case it failes in the Page_Load

     Greetings.

    Joey.

  • Re: Response.Redirect cannot be called in a page callback error message.

    06-30-2008, 9:35 AM
    • Member
      2 point Member
    • andymc33
    • Member since 06-30-2008, 9:31 AM
    • Posts 1

     

     

    jen_bonnett:

    Tried RegisterStartupScript, still nothing happens.

    Jennifer

    Hi, encountered the same problem today. The chart object has a callbackmanager property that allows execution of a script

     

    string script = "your script";
    Chart1.CallbackManager.ExecuteClientScript(script);

     Hope that helps,.

    Andy 

     

     

    Filed under:
Page 1 of 1 (11 items)