views:

80

answers:

2

I have many div in my aspx page. how to update the content of a particular div?

It should update every one minute time interval.. with out reloading entire page..

A: 

Certainly can do as Raj has pointed out but requires you to send back HTML code that is only thats needed. If you've got it in a ASPX page, it'll send the full HTML which is not that you want.

If you've done it with with MS-AJAX / UpdatePanel, you can use jQuery or a JavaScript timer to trigger a hidden button which will cause any server side code to update.

Please let me know if you want some examples

EDIT - new code sample

This is via jQuery, in the HTML HEAD

<style>
.hidden {visibility: none;}
</style>
<script type="text/javascript" language="javascript">
$(document).ready(function() {
    // this part will tell the MS AJAX framework to call SetupTrigger when the AJAX call back is done
    if (typeof Sys != "undefined") {
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(SetupTrigger);
    }
    SetupTrigger()
}
</script> 

Then in your HTML body

<script language="javascript">
function SetupTrigger() {
    var refresh = 60 * 1000;
    window.setTimeout(function() {
        TriggerUpdate();
    }, refresh);
}
function TriggerUpdate() {
   //simulates the button click
   $("#<%=btnUpdatePanel.ClientID%>").click();
}
</script>

<asp:UpdatePanel runat="server" ID="upPanel" UpdateMode="Conditional" ChildrenAsTriggers="true">
    <ContentTemplate>
            <asp:Button runat="server" ID="btnUpdatePanel" OnClick="ServerSideFunctionToCall" CssClass="hidden" />
    <!-- content to update -->
    </ContentTemplate>
</asp:UpdatePanel>
Jason Jong
thanks man...sure i need some example man....
Ayyappan.Anbalagan