开发者

Adding Chart Control at Runtime doesn't work (UpdatePanel/PostBack problem)

First, I want to refer to this post, I think it's the same problem:

http://social.msdn.microsoft.com/forums/en-us/MSWinWebChart/th开发者_StackOverflowread/B0594293-BB4B-4646-9CEF-8761AE02C005

I've got the following Code:

protected void LinkButton1_Click(object sender, EventArgs e)
{
  pnlTest.Controls.Add(GetChart());
  upnlTest.Update();
}

The chart simply isn't shown.

The link at the top now tells me I have to add the chart control in the Page_Load or Pre_Load but how do I get the fact that "LinkButton1" caused the PostBack.

Additional problem: Within the event handler LinkButton1_Click some data is being generated and should be used as input parameters for the GetChart() method.

Maybe someone could help me out?


The solution lies in the Web.config. It requires adding the "POST" verb to the httpHandler.

Before:

 <system.web>
   <httpHandlers>
       <add verb="GET,HEAD" path="ChartImg.axd"
            type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler,
            System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral,
            PublicKeyToken=31bf3856ad364e35" />
   </httpHandlers>

After:

<system.web>
  <httpHandlers>
       <add verb="GET,HEAD,POST" path="ChartImg.axd"
            type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler,
            System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral,
            PublicKeyToken=31bf3856ad364e35" />
  </httpHandlers>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜