2016-08-10 15 views
0

でタイマーを使用する場合:これは私のdiv要素で更新する前にクラスの競合私は、このコードとしてupdatePanalを使用して<code>asp.net</code>アプリケーションを構築しようとしているupdatePanal

 <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> 
        <asp:Timer runat="server" id="Timer1" Interval="10000" OnTick="Timer1_Tick"></asp:Timer> 

<asp:UpdatePanel ID="UpdatePanel1" runat="server"> 
    <Triggers> 
       <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" /> 
      </Triggers> 
    <ContentTemplate> 

      <div class="col-xs-6 col-md-3"> 
       <div class="panel panel-default"> 
        <div class="panel-body easypiechart-panel"> 
         <h4>Humidity </h4> 
         <div class="easypiechart" id="easypiechart-blue" data-percent="4" ><span class="percent">92%</span> 
         </div> 
                      <button class="btn btn-primary">Adjust Humidity</button><br /><br /><br /> 

        </div> 
       </div> 
      </div> 
     </ContentTemplate> 
      </asp:UpdatePanel> 

! :

enter image description here

これが起こる理由:それは、この変身更新後

enter image description here

答えて

0

おそらく、タイマが目盛りをつけているときにeasypiechartを再構築するjavascript関数を呼び出さなければならないでしょう。すべてのコードの

protected void Timer1_Tick(object sender, EventArgs e) 
{ 
    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "buildPie", "YourBuildPieFunction();", true); 
} 

UPDATE

まず不完全です。コメントに投稿したjavascriptには、document.getElementById('percentH').innerText = percentage + "%";という行があります。しかし、 "percentH"は存在しません。 <span>要素のIDは<span id="percentH" class="percent">92%</span>である必要があります。

第2に、piechartはそのコードによってビルドされていません。

$(function() { 
    $('.easypiechart').easyPieChart({ 
     //your configuration goes here 
    }); 
}); 

のScriptManagerによって呼び出される必要があるjavascriptのコードの一部です:あなたはhttps://rendro.github.io/easy-pie-chart/を使用したり、似たような場合は、どこかのページにこのような何かがあるはずです。

+0

ちょうどボタン、 'ClientScript.RegisterStartupScript(this.GetType()、 "updateProgress"、 "updateProgress(" "+ 100 +"'); ")で何時でも試してみました。 ' でも同じエラーです! –

+0

私はちょうど同様のパイチャートでテストしたところ、コードは機能しています。パイはUpdatePanel内でタイマーの更新やボタンのクリック後に再構築されます。あなたの質問にパイを構築するjavascriptコードを追加できますか? – VDWWD

+0

私はこの関数を使用しますupdateProgress(percentage){ document.getElementById( 'easypiechart-blue')。setAttribute( "data-percent"、percentage);document.getElementById( 'precentH')。innerText =パーセント+ "%"; } updatepanlなしでも動作しますが、使用するとうまくいきませんでした。 –

関連する問題