在gridview中没有调用VB.NET事件的ajaxFileUpload

时间:2015-02-10 22:21:13

标签: c# asp.net vb.net gridview

好的,我有一个vb gridview,如下所示:

<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",但仍然没有调用该事件。我只需要知道如何调用正确的事件而不仅仅是回发。感谢

1 个答案:

答案 0 :(得分:0)

如果您的网络配置确实如下所示:

<httpHandlers>
    <add verb="*" path="AjaxFileUploadHandler.axd"
      type="AjaxControlToolkit.AjaxFileUploadHandler, 
      AjaxControlToolkit"/>
</httpHandlers>