Hi Shahzad786,
Use SetInterval function.
HTML
<asp:ScriptManager runat="server" EnablePageMethods="true" />
<script type="text/javascript">
window.onload = function () {
// Set interval. Currently it is 1 sec.
setInterval(ShowMessage, 1000);
}
function ShowMessage() {
PageMethods.Message(Success, Failure);
function Success(result) { alert(result); }
function Failure(error) { alert(error); }
}
</script>
C#
[System.Web.Services.WebMethod]
public static string Message()
{
return "Welcome to ASPSnippets.com" + "\n\r" + DateTime.Now;
}
VB.Net
<System.Web.Services.WebMethod()>
Public Shared Function Message() As String
Return "Welcome to ASPSnippets.com" & vbLf & vbCr & DateTime.Now
End Function
Screenshot