ラベル built の投稿を表示しています。 すべての投稿を表示
ラベル built の投稿を表示しています。 すべての投稿を表示

2012年3月26日月曜日

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

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 hitTestResultAs Dundas.Charting.WebControl.HitTestResult = Chart1.HitTest(e.X, e.Y)If Not (hitTestResultIs Nothing)Then Dim clickedAs Dundas.Charting.WebControl.DataPoint = hitTestResult.Series.Points(hitTestResult.PointIndex)Select Case hitTestResult.PointIndexCase 0 Response.Redirect("COQuotes.aspx")Case 1 Response.Redirect("COOrders.aspx")Case 2 Response.Redirect("COOrders.aspx")End Select End If

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


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 hitTestResultAs Dundas.Charting.WebControl.HitTestResult = Chart1.HitTest(e.X, e.Y)If Not (hitTestResultIs Nothing)Then Dim clickedAs Dundas.Charting.WebControl.DataPoint = hitTestResult.Series.Points(hitTestResult.PointIndex)Select Case hitTestResult.PointIndexCase 0 clientRedirect("COQuotes.aspx")Case 1 clientRedirect("COOrders.aspx")Case 2 clientRedirect("COOrders.aspx")End SelectSub clientRedirect(ByVal URL)Dim jScriptAs String jScript =String.Format("document.location.href ='{0}');", URL) ClientScript.RegisterClientScriptBlock(Page.GetType(), "redirect", jScript,True)End Sub


GiveRegisterStartupScript a try. Seehttp://blogs.ittoolbox.com/c/coding/archives/registerclientscriptblock-and-registerstartupscript-17321 for some more info.

-Damien


Tried RegisterStartupScript, still nothing happens.

Jennifer


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


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.

2012年3月24日土曜日

Rounded Corners - Bizarre Width Effects

I'm new to Ajax and just built a web page to test assorted effects that I want to use right away. One of the most straightforward - Rounded Corners - I can't get working correctly. Here are two screenshots exemplifying the problem:

Here's the pertinent HTML and CSS code:

<%@dotnet.itags.org. Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Ajax_Test_1._Default" %>
<%@dotnet.itags.org. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<link href="http://links.10026.com/?link=styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<br /
<div>
Rounded corners:<br />
<asp:LinkButton ID="LinkButton1" runat="server" CssClass="purpleButton" BackColor="#C0C0FF">Dummy Link</asp:LinkButton>
<cc1:RoundedCornersExtender ID="RoundedCornersExtender1" runat="server" TargetControlID="LinkButton1" BorderColor="128, 128, 255" Color="192, 192, 255" Radius="6">
</cc1:RoundedCornersExtender>

purpleButton
{
background-color:#C0C0FF;
width:75px;
text-align:center;
}

.modalBackground
{
background-color:Gray;
filter:alpha(opacity=70);
opacity:0.7;
}

.modalPopup
{
background-color:#ffffdd;
border-width:3px;
border-style:solid;
border-color:Gray;
padding:3px;
width:250px;
}

It's strange that the width value in the CSS file has no effect. Yet if I specify the width directly in the HTML then it fixes the problem in IE7. Nothing I do seems to change anything in Firefox 2.0

Any ideas?

Robert Werner
Vancouver, BC

Add display: block; to your purpleButton class. That'll fix it.


Just tried what you suggested. Sorry, but this doesn't do a thing. Here's the full source code: http://mwtech.com/downloads/public/AjaxTest.zip

Robert


display: block; is necessary, but you also need to add a "." before purpleButton in your CSS. The class name needs to be .purpleButton in styles.css for it to be available for reference as purpleButton in the CssStyle property in your asp.net code.


You are correct! Thank you for that tip!

I just removed all width settings from the HTML and found that in the CSS I had to set "width" to some value first before I could control the actual width using "min-width". Very odd IMHO. Maybe one day I'll fully understand all the quirks of CSS!!!

Robert