Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
iam working on asp.net4 web site
i have issue
that i want user to be notified for table change
meaning
every time row insretd in speicif table
update no of rows in user interface
so i add label in master page
& i add timer & every helf second i call function that get the total rows from this table
but i hvae 1 problem
page is render it self when calling timer_tick event
i aready have updatepanel in master page call updatepanel1
so i add another updatelpanel updatepanel2

ASP.NET
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional" >
   <ContentTemplate>
   <asp:Timer ID="Timer1" Interval="250" runat="server" ontick="Timer1_Tick"/>
   </ContentTemplate>
   </asp:UpdatePanel>

but the page is render when i open any page i can't edit in it becasue page is render it doesn't dir any reload for me but it's render with every call to the timer event
so what i need is calling timer control with out effect page or whole site partial render for label that fir rows count
timer control is in master page
Posted
Updated 4-Oct-11 20:13pm
v2
Comments
kennytan_ph 5-Oct-11 7:46am    
It would be helpful if you can provide the complete page code.

Also, querying the database every half-second will cause considerable performance issue.

This might sound darft but is your UpdatePanel doing it's job correctly? Ie. do you have a means of calling the partial postback? You need a trigger or a piece of javascript that will fire the postback ie.

function doSubmit()
{
$get('timervalue').value++;
__doPostBack('updatepanelid',args);
}
 
Share this answer
 
The most obvious question is: are you sure you need this in your UI?

This design will cause the full page to run on the server 4 times per second for each user. This is not ideal.

If you really need this functionality, you could use an AJAX call to a web service and use the result to update a single DOM element. jQuery can do this but it will require some work to make it robust.
 
Share this answer
 
i found the solution after hard search
first i'll create web service that have my function that get data
then in master page
in java scrit i'll call timer event

<script type="text/javascript">
function pageLoad(sender, args) {
// Update the screen display and then have it updated every 10 Minutes...
UpdateOpenWorkItemCount();

setInterval('UpdateOpenWorkItemCount();', 600000);
}

function UpdateOpenWorkItemCount() {
// Call the GetOpenWorkOrders Web Service
WebsiteServices.GetOpenWorkOrders(GetOpenWorkOrdersOnSuccess, GetOpenWorkOrdersOnFailed);
}

C#
function GetOpenWorkOrdersOnSuccess(results) {
            // Display results in workItemCount
            if (results >= 0) {
                var workItemCount = document.getElementById('<%=WorkItemCountLink.ClientID %>');
                if (workItemCount) {
                    workItemCount.innerHTML = results + ' open work items';

                    if (results == 0)
                        workItemCount.style.color = 'White';
                    else
                        workItemCount.style.color = 'Yellow';
                }

                // Update the page's title
                document.title = originalTitle + ' (' + results + ')';
            }
        }

        function GetOpenWorkOrdersOnFailed(results) {
            alert('There was an error calling the Add service: ' + results.get_message());
        }





<asp:scriptmanager id="myScriptManager" runat="server" xmlns:asp="#unknown">
<services>
<asp:servicereference path="~/Services/WebsiteServices.asmx">



so it call my method from java script depending on interval second without rendering my page
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900