Is it possible to to programmatically trigger a postback from server code in ASP.NET? I know that it is possible to do a Response.Redirect or Server.Transfer to redirect to
If you are looking to initiate communication from the server, rather then polling, have a look at Microsoft's SignalR. The easiest context for this, and one the SignalR has as part of its example code is a chat application. You will be able to initiate messages from code behind and receive them as javascript events on your page.
Server Code To Send:
using System;
using System.Web;
using Microsoft.AspNet.SignalR;
namespace SignalRChat
{
public class ChatHub : Hub
{
public void Send(string name, string message)
{
// Call the broadcastMessage method to update clients.
Clients.All.broadcastMessage(name, message);
}
}
}
Client Code to catch server messages is the override of 'chat.client.broadcastMessage':