又遇到了一个路障。现在我有一个页面,其中包含Plupload
一个转发器,它基本上从数据库中提取所有上传的图像。此页面在 中动态加载colorbox
。
我需要的是转发器在新图像上传到数据库时自行更新。为此,我只需调用中继器并对其进行数据绑定 (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
控件,因为当通过颜色框加载页面时它似乎无法正常工作。(如果有人对此有解决方案,那就太棒了,因为这会简化一切哈哈)
我不确定是否有用的另一条信息是转发器绑定在 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();
}
});