Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Can';无法使计时器事件处理程序工作_C#_Asp.net_Timer - Fatal编程技术网

C# Can';无法使计时器事件处理程序工作

C# Can';无法使计时器事件处理程序工作,c#,asp.net,timer,C#,Asp.net,Timer,在第页上,我有一个UpdatePanel和一个运行良好的计时器: <asp:Content ID="content" ContentPlaceHolderID="contentholder" runat="server"> <asp:ScriptManager runat="server" EnablePartialRendering="true" ID="ScriptManager"></asp:ScriptManager> <asp

在第页上,我有一个UpdatePanel和一个运行良好的计时器:

<asp:Content ID="content" ContentPlaceHolderID="contentholder" runat="server">
    <asp:ScriptManager runat="server" EnablePartialRendering="true"  ID="ScriptManager"></asp:ScriptManager>
    <asp:Timer ID="Timer" runat="server" Interval="10000" ></asp:Timer>
    <asp:UpdatePanel ID="MainUpdatePanel" runat="server">
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="Timer" EventName="Tick" />
        </Triggers>
        <ContentTemplate>
<!-- some content, including repeaters... -->
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>

我可以看到在调试期间,
Timer.Tick+=
发生得很好,但是
\u someFlag
从不更改其值,并且
\u someFlag=true也不会发生。我遗漏了什么?

您必须向计时器添加
OnTick=“Timer\u Tick”
属性:

<asp:Timer runat="server" id="Timer1" Interval="10000" OnTick="Timer_Tick"></asp:Timer>

您必须向计时器添加
OnTick=“Timer\u Tick”
属性:

<asp:Timer runat="server" id="Timer1" Interval="10000" OnTick="Timer_Tick"></asp:Timer>

将“计时器”放在“更新面板”和“内容模板”标记内以处理触发事件

将“计时器”放在“更新面板”和“内容模板”标记内以处理触发事件

可能是因为您没有向函数添加新的事件处理程序
计时器勾号计时器是从任何地方启动的吗?此链接是否有帮助您的完整性可能是您没有在函数
计时器_Tick
中添加
新事件处理程序
计时器
是否在任何地方启动?此链接可能有助于您的完整性否,仍然是相同的结果。否,仍然是相同的结果。
Timer.Tick += Timer_Tick;