Im trying to trigger callback of CallbackPanel with javascript in my WebFormUserControl every 10 seconds.
Im able to trigger it with ASPxButton and ClientSideEvents, but my goal is to start it automatically every 10 seconds.
My UserControl code:
<dxcb:ASPxCallbackPanel ID="panel" runat="server" ClientInstanceName="panel" OnCallback="ASPxCallbackPanel1_Callback" Width="200px">
<PanelCollection>
<dxcb:PanelContent runat="server">
<dxcb:ASPxImage ID="ASPxImage1" runat="server" ImageUrl="~/Images/Image1.png" ShowLoadingImage="true"></dxcb:ASPxImage>
</dxcb:PanelContent>
</PanelCollection>
</dxcb:ASPxCallbackPanel>
<dxcb:ASPxButton ID="ASPxButton1" runat="server" AutoPostBack="false" Text="ASPxButton">
<ClientSideEvents Click="function(s, e) { panel.PerformCallback(); }" />
</dxcb:ASPxButton>
I tried to fire it ever 10 seconds like this:
<script type='text/javascript'>
setInterval(function () { panel.PerformCallback(); }, 10000);
</script>
Is is possible to achieve my goal?
If so, please provide some useful code.
Thanks :)
答案 0 :(得分:0)
You can use __doPostBack
while passing the id of your CallBackPanel. Like this:
<script type='text/javascript'>
setInterval(function () {
__doPostBack("<%= panel.ClientID %>", "PanelCalledBack");
}, 10000);
</script>
Then check against your passed PanelCalledBack
argument in your panel's OnLoad
event (if it has one) or in the Page_Load
event:
if (Request.Params.Get("__EVENTARGUMENT")?.Trim().IndexOf("PanelCalledBack") != -1)
{
ASPxCallbackPanel1_Callback(panel, null);
}