为什么我无法在其他浏览器中更新Gridview [英] Why I Can't Update Gridview In Other Browser

查看:92
本文介绍了为什么我无法在其他浏览器中更新Gridview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在当前浏览器中上传文件时,我想在其他浏览器中更新我的gridview ..我使用signalR来实现..这是我的源代码..这里是我的NotificationHub.vb



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)
            ' Call the broadcastMessage method to update clients.
            Clients.All.broadcastMessage(name, message)
        End Sub
    End Class
End Namespace





这是Startup.vb





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





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);
        })



和最后一个home.aspx.vb(我在上传代码后写这段代码)




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 :)

推荐答案

.connection.NotificationHub;
NotificationHub.client.refresh = function(stock){

// Just一些跟踪目的
// console.log('刷新方法已成功触发!');
// console.log(stock);

// 使用最新数据刷新gridview
.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
("#Gridview1").each(function (i) { if (


(< code>< / code> this)[ 0 ]。id == stock.ID){
// 突出显示已更改数据的行n慢慢淡出
(<code></code>this)[0].id == stock.ID) { //highlight the row that has data changed then slowly fade


这篇关于为什么我无法在其他浏览器中更新Gridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆