0

リピーターのあるページでタイマーを使用すると問題が発生します。
私のページは基本的に次のようになります:(すべてのラベルやその他の重要でないものを書き留めていませんでした。ページはかなり大きいです)

<asp:Timer runat="server" Interval="5000" OnTick="UpdateTimer_Tick" ID="UpdateTimer" />
<UpdatePanel 1>
<dropdownlist/>
<Panel 1>
    <TextBox/><Button/>
</Panel 1>

<Repeater 1> //Bound to a list in code behind
    <Checkbox/><textbox/>
</Repeater 1>
<Button/>

<Repeater 2> //Bound to a list in code behind
    <button/><button/>
</Repeater 2>

<Repeater 3> //Bound to a dataset in code behind
    <textbox/><button/><button/>
</Repeater 3>
<button/><button/><button/>
</UpdatePanel 1>
<panel 2>
   //Jscript stuff that doesn't change anything to my current problem.
</panel 2>
<UpdatePanel 2>
    <Image/>
</UpdatePanel 2>

私のページでは、5000 ミリ秒のタイマーを追加しようとしています。更新された情報を表示するためにリピーターをリロードしたいだけなので、OnTick イベントは BindRepeater2 メソッドを呼び出す必要があります。
updatePanelの前、内側、後、パネル1、パネル2、リピーターにタイマーを配置してみました。リピーターごとに複数の updatePanel を用意してみました。どこにでもパネルを配置してみました...得られた最良の結果は、パネル 1 の textBox がその中の情報を失わないことでした。UpdatePanel2 の画像は常に消え (ポストバックでない場合は pageLoad で一度バインドするため)、repeater1 のテキストボックスは常にリセットされます。その上、ドロップダウン リストを参照すると、OnTick イベントがテキスト ボックスのフォーカスを失い、左クリックします。

この問題を解決する方法についてのアイデアがありません。

編集: ajax を使用してリピーターを構築できることがわかりました。しかし、私はそれを行う方法の手がかりがありません。誰でも私を説明できますか?

4

2 に答える 2

1

UpdateMode= "Conditional"プロパティを UpdatePanel に追加し、リピーター セットをバインドした後に OnTick イベントに追加します。UpdatePanel1.update();


OnTick イベント

protected void Timer1_Tick(object sender, EventArgs e)
    {
        BindRepeater();
        UpdatePanel1.update();
    }
于 2013-02-28T15:05:40.930 に答える
0

私のページを微調整した後、私はこれに行き着きました。

<asp:Timer runat="server" Interval="5000" OnTick="UpdateTimer_Tick" ID="UpdateTimer" />
<UpdatePanel1 UpdateMode="Conditional">
<dropdownlist/>
<Panel 1>
    <TextBox/><Button/>
</Panel 1>
<Repeater 1> //Bound to a list in code behind
    <Checkbox/><textbox/>
</Repeater 1>
<Button/>
</UpdatePanel1>

<UpdatePanel2 UpdateMode="Conditional">
<Repeater 2> //Bound to a list in code behind
    <button/><button/>
</Repeater 2>
</UpdatePanel2>

<UpdatePanel3 UpdateMode="Conditional">
<Repeater 3> //Bound to a dataset in code behind
    <textbox/><button/><button/>
</Repeater 3>
<button/><button/><button/>
</UpdatePanel3>

<UpdatePanel4 UpdateMode="Conditional">
<panel 2>
   //Stuff
</panel 2>
    <Image/>
</UpdatePanel4>

コードビハインドでの使用

protected void Timer1_Tick(object sender, EventArgs e) 
{ BindRepeater(); UpdatePanel2.Update(); }
于 2013-02-28T16:59:43.807 に答える