I placed a label that named as LabelTotalNumber on Asp.net webform. I want update a value every one minute by jQuery without refresh the form. How do I do it?
I can do this way in Page_Load event for one time.
var sqlResult = (From obj in db.RequestList
where obj.IsApproved == "Approved"
select obj).count();
LabelTotalNumber.text = sqlResult;
Out-of-the-Microsoft-box you could use an UpdatePanel and a Timer.
If you don’t like the contents of the Microsoft box and wanna use jQuery/javascript you could send AJAX requests at regular intervals (using the
window.setIntervalmethod) to an ASP.NET PageMethod (in which case basically you will have to give yourself a little pain to read jQuery’s documentation/tutorials and write a little code).So an ASP.NET PageMethod:
and then hammer this PageMethod with an AJAX request every minute or so: