2012-07-08 90 views
2

后跌进另一个障碍。现在我有一个包含Plupload的页面和一个基本上从数据库中提取所有上传图像的中继器。此页面在colorbox中动态加载。执行vb.net代码方法背后Plupload完成上传

我需要的是当新图像上传到数据库时,中继器要自行更新。我只需调用Repeater并将其绑定(Repeater1.Databind())即可。我非常肯定解决方案在于Ajax,但我环顾四周,甚至用它们来调用Web服务,但是如何在方法后面执行代码?

背后,我想执行方法的代码是:

Public Sub reBind() 
    Dim dt2 As DataTable = blOrgLogo.getOrgLogo(userId, False).Tables(0) 
    If (dt2 Is Nothing) Or (dt2.Rows.Count = 0) Then 
     ' Nothing is returned 
    Else 
     repLogoCollection.DataSource = dt2 
     repLogoCollection.DataBind() 
    End If 
End Sub 

一个例子,我看到在线状态这是可以做到使用PageMethods但我不能让它使用上述方法工作。

我不能使用ASP.Net Ajax Timer控件,因为当页面通过colorbox加载时,它似乎不工作。 (如果有人有这个解决方案,这将是真棒,因为这将简化一切哈哈)

另一条信息,我不知道可能有任何用处是中继器绑定在page_load。

Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load 
    userId = Session("UserID") 
    Dim dt As DataTable = blOrgLogo.getOrgLogo(userId, False).Tables(0) 

    If (Not IsPostBack) Then 
     If (dt Is Nothing) Or (dt.Rows.Count = 0) Then 
      ' Nothing is returned 
     Else 
      Repeater1.DataSource = dt 
      Repeater1.DataBind() 
     End If 
    End If 
End Sub 

的Plupload的javascript:

// Client side form validation 
$('#uploader').submit(function (e) { 
    var uploader = $('#uploader').pluploadQueue(); 

    // Validate number of uploaded files 
    if (uploader.total.uploaded == 0) { 
     // Files in queue upload them first 
     if (uploader.files.length > 0) { 
      // When all files are uploaded submit form 
      uploader.bind('UploadProgress', function() { 
       if (uploader.total.uploaded == uploader.files.length) 
        $('form').submit(); 
      }); 

      uploader.start(); 


     } else 
      alert('You must at least upload one file.'); 

     e.preventDefault(); 
    } 
}); 
+0

上传后为什么不重新加载页面?它似乎很复杂,你简单的任务做什么, – ppumkin 2012-07-11 16:00:28

+0

的页面是在颜色框这就是为什么我想要做这种方式。但最有可能的是我会抛弃colorbox – 2012-07-12 13:24:45

+0

好吧,它不是一个iframe或在colorbox中的东西?如果是这样iframe iframe ..如果它的ajaxed html ..然后重新ajax它? :) – ppumkin 2012-07-12 14:28:22

回答

1

您将需要使用

$.ajax({ 
      type: "POST", 
//Location to the webservice or the webmethod 
      url: "Services/Service.asmx/reBind", 
      contentType: "application/json; charset=utf-8", 
      dataType: "json", 
      success: function(data) { 
      //on success  
      }, 
      error: function(ex) { 
      //on error    
      } 
     }); 

和上面的方法添加[WebMethod(true)]你可能需要找的这个vb.net equivalant作为是我用于C#的。

至于Ajax调用林不知道,如果你必须有一个Web服务的代码,我敢肯定,即使它是在一个类中,将工作,你可能必须尝试两者。

+0

感谢您的帮助,现在作品:D – 2012-07-17 16:02:25