Widget Autorefresh

Topics: Controls
Feb 4, 2012 at 1:49 AM

I want to add a webcam image within the Textbox Widget.  Does anyone know of a way to have the widget update itself at a specified interval?  I don't want the primary site refresh, just the widget or the image within the widget.

Feb 4, 2012 at 4:16 AM

If you look at most of the admin/settings pages, "save" button does Ajax call instead of postback. You'd need do similar - load widget content with JavaScript calling web method in code behind and repeating it using JS timer. Callback function would reload only "div" content.

Feb 8, 2012 at 7:02 PM

I believe I got this work work using just simple javascript.  Now to fire up the webcam..

<p><a title="Webcam at Flentje Headquarters" href="http://www.flentje.com/Images/other/webcam.jpg" target="_blank"><img id="webcam" src="http://www.flentje.com/Images/other/webcam.jpg" alt="" name="webcam" width="200" height="150" border="0" /></a></p>
<p>Webcam at Flentje Headquarters</p>

<script type="text/javascript" language="JavaScript">// <![CDATA[
function reloadImage() {
    var now = new Date();
    if (document.images) {
        document.images.webcam.src = 'http://www.flentje.com/Images/other/webcam.jpg?' + now.getTime();

// ]]></script>