0
好吧,我有一個VB GridView控件,看起來像這樣:ajaxFileUpload在GridView不調用VB.NET事件
<asp:GridView ID="grvMain" Width="100%" runat="server">
<Columns>
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:Panel ID="pnlEdit" runat="server" Visible="False" Font-Size="15px">
<asp:AjaxFileUpload OnUploadComplete="AjaxFileUploadEvent" ID="AjaxFileUpload11" runat="server" MaximumNumberOfFiles="1" />
</asp:Panel>
<asp:LinkButton CommandArgument="<%# Container.DataItemIndex %>" ID="lbtnIcon" runat="server">View</asp:LinkButton>
</ItemTemplate>
<ItemStyle />
</asp:TemplateField>
</Columns>
</asp:GridView>
頁面的其餘部分是無關緊要的,但我有一切,使ajaxFileUpload工作的代碼。我遇到的問題是,當fileupload在gridview中時,它不會調用它在gridview外部調用的事件。
這裏是我的Gridview代碼。
Public Sub grvMain_RowCommand(sender As Object, e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles grvMain.RowCommand
Dim intIndex As Integer = Convert.ToInt32(e.CommandArgument)
Dim pnlEdit As Panel = grvMain.Rows(intIndex).FindControl("pnlEdit")
pnlEdit.visible = true
End Sub
所以當在GridView按LinkButton的啓用它包含文件上傳面板。
代碼爲OnUploadComplete事件是:
Sub AjaxFileUploadEvent(sender As Object, e As System.EventArgs)
Dim filename As String = System.IO.Path.GetFileName(e.FileName)
Dim strUploadPath As String = "~/images/"
AjaxFileUpload11.SaveAs(Server.MapPath(strUploadPath) + filename)
End Sub
所有的代碼做的是保存在文件夾中文件。此外,我已經嘗試將ajaxfileupload更改爲OnClientUploadComplete="AjaxFileUploadEvent"
,但它仍不會調用該事件。我只需要知道如何使它調用正確的事件,而不是僅僅做回發。由於
是我必須在我的網絡配置文件。我也有<%@ Register Assembly =「AjaxControlToolkit」Namespace =「AjaxControlToolkit」TagPrefix =「asp」%>我在頁面上有一個腳本管理器 – adouglsh9 2015-02-10 22:43:04
如果您將控件移動/包裝在UpDatePanel中,會發生什麼... ?我正在嘗試在C#中的相同的東西,我沒有問題。 – MethodMan 2015-02-11 14:06:25
當我把ajaxfileupload放在更新面板裏時,它給了我類型'System.web.ui.updatepanel'沒有名爲' ajaxfileupload' – adouglsh9 2015-02-11 14:22:33