hybridmatt

AJAX ModalPopupExtender & IE6

Recommended Posts

I've added a chart to my ASP .NET page, and made the chart a hotspot via the 'clickURL' property. When the user clicks the chart, I want to display a larger version in an AJAX Modal popup. This works fine in IE7, but won't work correctly in IE6. The pop-up appears but says 'No Data to display'. If I then hit F5 (refresh), it works fine (until I post-back then it's back to 'no Data...' and F5 to make it work again). I've pasted some test code below which works fine in IE7, but the above issue in IE6. Is there another way I can achieve this...or am I doing something incorrect? Thanks.

default.aspx

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>

<!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">

  <SCRIPT LANGUAGE="Javascript" SRC="/FusionCharts/Includes/FusionCharts.js"></SCRIPT>

  <link href="StyleSheet.css" rel="stylesheet" type="text/css" />

  <title></title>

  <script>

  function showModal() {

  var strURL = "modalChart.aspx";

  strURL = escape(strURL);

  var chartObj = getChartFromId("modalChart");

  chartObj.setDataURL(strURL);

 

  $find("ModalPopupExtender1").show();

  }

  </script>

</head>

<body>

  <form id="form1" runat="server">

  <ajaxToolkit:ToolkitScriptManager runat="Server" EnableScriptGlobalization="true" EnableScriptLocalization="true" ID="ScriptManager1" />

  <center>

  <%=GetChartHtml()%>

  </center>

  <div style="display:none; visibility:hidden;">

  <asp:Button runat="server" ID="hiddenButton" />

  </div>

  <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="hiddenButton" PopupControlID="PNL" OkControlID="ButtonOk" />

  <asp:Panel ID="PNL" runat="server" style="width:800px; height:500px; background-color:White; border-width:2px; border-color:Black; border-style:solid; padding:6px;">

  <center>

  <%=GetModalChartHtml()%>

  <br />

  <asp:Button ID="ButtonOk" runat="server" Text="OK" />

  </center>

  </asp:Panel> 

  </form>

</body>

</html>

default.aspx.vb

Imports System.Data

Imports System.Data.SqlClient

Imports InfoSoftGlobal

Imports System

Imports System.Web.UI

Imports System.Web.UI.WebControls

Imports System.Web.UI.HtmlControls

Partial Class _Default

  Inherits System.Web.UI.Page

  Public Function GetChartHtml() As String

  Dim xmlData As StringBuilder = New StringBuilder()

  xmlData.Append("<chart clickURL='javascript:showModal()' decimals='2' labelstep='2' imageSave='1' drawAnchors='1' anchorAlpha='100' slantLabels='1' borderAlpha='100'><categories>")

  xmlData.Append("<category label='7/23/2008' />")

  xmlData.Append("</categories>")

  xmlData.Append("<dataset>")

  xmlData.Append("<set value='100' />")

  xmlData.Append("</dataset></chart>")

  Return FusionCharts.RenderChart("/FusionCharts/Charts/MSColumn3d.swf", "", xmlData.ToString(), "test", "435", "228", False, True)

  End Function

  Public Function GetModalChartHtml() As String

  Return FusionCharts.RenderChart("/FusionCharts/Charts/MSColumn3d.swf", "", "<chart></chart>", "modalChart", "760", "425", False, True)

  End Function

End Class

modalChart.aspx

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="modalChart.aspx.vb" Inherits="modalChart" %>

modalChart.aspx.vb

Imports System.Data

Imports System.Data.SqlClient

Partial Class modalChart

  Inherits System.Web.UI.Page

  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Dim xmlData As StringBuilder = New StringBuilder()

 

  xmlData.Append("<chart decimals='2' labelstep='2' imageSave='1' drawAnchors='1' anchorAlpha='100' borderAlpha='100'><categories>")

  xmlData.Append("<category label='7/24/2008' />")

  xmlData.Append("</categories>")

  xmlData.Append("<dataset>")

  xmlData.Append("<set value='200' />")

  xmlData.Append("</dataset></chart>")

  Response.ContentType = "text/xml"

  Response.Output.Write(xmlData.ToString())

  End Sub

End Class

Share this post


Link to post
Share on other sites

Hi cawthor,

You can write this program using ajax postback of chart as well as the XML. I have modified your program. I am using here ICallbackEventHandler as implement. Now modal popup is working perfectly. Could you please try and apply it in your code and give us your valuable feedback?

ModalPopUP_Code.zip

Share this post


Link to post
Share on other sites

Thank You! This works perfectly! I can't say I fully understand 'how' this works, I'm slightly confused as to what is happening in the following lines of code. But thanks once again!

' Ajax Control Adding

Dim cm As ClientScriptManager = Page.ClientScript

Dim cbReference As String = cm.GetCallbackEventReference(Me, "arg", "ReceiveServerData", "context")

' Add Javascript on page

Dim callbackScript As String = "function CallServer(arg, context)" + "{" + cbReference + "; }"

cm.RegisterClientScriptBlock(Me.GetType(), "CallServer", callbackScript, True)

[code]

Share this post


Link to post
Share on other sites

Is there a copy of the ModalPopUP_code.zip for C#. If there is can you please e-mail it to me, because I cannot read the attachment here.

 

 

 

Thanks,

 

 

 

Matt

Share this post


Link to post
Share on other sites

Do you have a C# version of that code? I know VB and C# are both .NET but I am unfamiliar with VB. If you have done a C# version of the modal pop-up can you please post that code.

 

 

 

Thanks,

 

 

 

hybridmatt

Share this post


Link to post
Share on other sites

Hi,

 

 

 

We have the same issue and is very critical part of our product. The attachment goes to some other page and am unable to download. Can you please reattach the zip file or post the fix in forum.

 

 

 

Thanks,

 

Sarva

Share this post


Link to post
Share on other sites

I am experiencing the same issues as the previous posters of this blog.  I also would like a copy of the C# code that is referenced, but I am also unable to download it.  Right clicking the attachment ( ModalPopUP_C#_Code.zip) and selecting Save As only saves a web page (forum.html) and not a zip file containing C# code. Could you provide me with a place where I can download this C# package?

Thanks in advance!

Share this post


Link to post
Share on other sites

I'm unable to make it work for master page scenario. The following event is not firing in master/content page scenario.

javascript:CallServer(%26apos;Fact1%26apos;,%26apos;%26apos;);

 

Same coding setup works if it is without master page setup.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now