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.vbImports System.Web
Imports Microsoft.AspNet.SignalR
Namespace SignalRChat
Public Class NotificationHub
Inherits Hub
Public Sub Send(name As String, message As String)
' Call the broadcastMessage method to update clients.
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
'add the attribute here
<Assembly: OwinStartup(GetType(SignalRTutorials.Startup))>
Namespace SignalRTutorials
Public Class Startup
Public Sub Configuration(app As IAppBuilder)
'app.MapSignalR()
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) {
//Just some tracing purposes
//console.log('Refresh method triggered successfully!');
//console.log(stock);
//Refresh the gridview with latest data
$("#Gridview1").each(function (i) {
if ($(<code></code>this)[0].id == stock.ID) {
//highlight the row that has data changed then slowly fade
$(this).attr('style', 'background-color: yellow;');
$(this).animate({ backgroundColor: 'white' }, 3000);
}
});
};
$.connection.hub.start().done(function () {
//Just to trace whether your browser successfully connected to SignalR hub
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