Ferry Jongmans
Ferry Jongmans

Reputation: 664

ASP.NET Timer refreshes the comlete page

I have started a project, with an imagebox who is updating each new frame. But my ASP.NET timer updates the whole page... This is the demo of my project, with the live view.. click on "Live beeld" : Application

The application is not encrypted with password yet...

protected void tmrLive_Tick(object sender, EventArgs e)
{
    if (Label1.Text != ""&& Label1.Text!="")
    {
        liveUriList.Items.Clear();
        CloudBlobClient blobClient = new CloudBlobClient("http://ferryjongmans.blob.core.windows.net/", new StorageCredentialsSharedAccessSignature(signature.Text));
        CloudBlobContainer container = blobClient.GetContainerReference(cameraList.Items[Convert.ToInt32(Label1.Text)].ToString());
        CloudBlobDirectory direct = container.GetDirectoryReference(cameraList.Items[Convert.ToInt32(Label1.Text)].ToString());
        BlobRequestOptions options = new BlobRequestOptions();
        options.UseFlatBlobListing = true;
        options.BlobListingDetails = BlobListingDetails.Snapshots;
        foreach (var blobItem in direct.ListBlobs(options))
        {
             string uri = blobItem.Uri.ToString();
             Regex regex = new Regex(comboBox1.SelectedItem.ToString() + "/(.*).jpeg");
             var v = regex.Match(blobItem.Uri.ToString());
             string s = v.Groups[1].ToString();
             pictureBox2.ImageUrl = uri + signature.Text;
        }
    }
}

I Hope someone can help me with building a nice timer who is not refreshing my whole page..

Upvotes: 1

Views: 5949

Answers (1)

scartag
scartag

Reputation: 17680

You should wrap the area you want to update (refresh) within an UpdatePanel. The timer itself should be inside this UpdatePanel

Add the section in your page and put the controls you want to update/refresh within the contenttemplate section of the UpdatePanel.

<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">

 <ContentTemplate>
        <asp:Image ID="pictureBox2" runat="server"></asp:Image>
    <asp:Timer ID="tmrLive" runat="server" OnTick="tmrLive_Tick"></asp:Timer>
 </ContentTemplate>
</asp:UpdatePanel>

Upvotes: 2

Related Questions