I want to update my gridview in other browser when i upload file in current browser..i use signalR to implement that.. here is my source code.. here is my NotificationHub.vb
Imports System.Web
Imports Microsoft.AspNet.SignalR
Namespace SignalRChat
Public Class NotificationHub
Inherits Hub
Public Sub Send(name As String, message As String)
Clients.All.broadcastMessage(name, message)
End Sub
End Class
End Namespace
Here is Startup.vb
Imports Microsoft.AspNet.SignalR
Imports Microsoft.Owin.Security
Imports Owin
Imports Microsoft.Owin
<Assembly: OwinStartup(GetType(SignalRTutorials.Startup))>
Namespace SignalRTutorials
Public Class Startup
Public Sub Configuration(app As IAppBuilder)
Dim hubConfiguration = New HubConfiguration()
hubConfiguration.EnableDetailedErrors = True
hubConfiguration.EnableJavaScriptProxies = True
app.MapSignalR("/signalr", hubConfiguration)
End Sub
End Class
End Namespace
in home.aspx
var NotificationHub = $.connection.NotificationHub;
NotificationHub.client.refresh = function (stock) {
$("#Gridview1").each(function (i) {
if ($(<code></code>this)[0].id == stock.ID) {
$(this).attr('style', 'background-color: yellow;');
$(this).animate({ backgroundColor: 'white' }, 3000);
}
});
};
$.connection.hub.start().done(function () {
console.log('Connected to SignalR hub, connection ID = ' + $.connection.hub.id);
})
and the last in home.aspx.vb (i write this code after upload's code)
Dim context = GlobalHost.ConnectionManager.GetHubContext(Of NotificationHub)()
Dim aTimer = New System.Timers.Timer(1000)
aTimer.Interval = 3000
aTimer.Enabled = True
context.Clients.All.refresh()
i hope you can help me everyone.. thanks :)