Asp.net Plupload完成上传后执行vb.net代码隐藏方法
跌入另一个路障。现在我有一个包含Asp.net Plupload完成上传后执行vb.net代码隐藏方法,asp.net,.net,ajax,vb.net,plupload,Asp.net,.net,Ajax,Vb.net,Plupload,跌入另一个路障。现在我有一个包含Plupload的页面和一个转发器,基本上可以从数据库中提取所有上传的图像。此页面在颜色框中动态加载 我需要的是,当新图像上传到数据库时,中继器会自动更新。我只需调用中继器并对其进行数据绑定(Repeater1.databind())。我很确定解决方案在于Ajax,但我已经环顾四周,甚至用它们来调用web服务,但是如何执行代码隐藏方法呢 我要执行的代码隐藏方法是: Public Sub reBind() Dim dt2 As DataTable = blO
Plupload
的页面和一个转发器,基本上可以从数据库中提取所有上传的图像。此页面在颜色框中动态加载
我需要的是,当新图像上传到数据库时,中继器会自动更新。我只需调用中继器并对其进行数据绑定(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加载页面时,它似乎不起作用。(如果有人能解决这个问题,那就太棒了,因为这会简化一切,哈哈)
另一条我不确定是否有用的信息是,转发器绑定在页面加载中
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();
}
});
您需要使用
$.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,因为这就是我在c#中使用的
至于ajax调用,我不确定您是否必须在web服务中使用该代码,我非常确定,即使它在类中也可以使用,您可能必须同时尝试这两种方法。为什么不在上传后重新加载页面?对于一个简单的任务,你所做的似乎很复杂,页面在一个颜色框中,这就是为什么我想这样做。但最有可能的是我会扔掉配色箱好吧,它不是iframe还是配色箱里的什么?如果是,请重新标记iframe。。如果是ajaxed html。。那么你要重新开始吗?:)