简体   繁体   English

GridView中的ajaxFileUpload不调用VB.NET事件

[英]ajaxFileUpload in a gridview not calling VB.NET Event

Okay I have a vb gridview that looks like this : 好吧,我有一个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>

The rest of the page is irrelevant but I do have all the code that makes the ajaxFileUpload work. 页面的其余部分无关紧要,但是我确实拥有使ajaxFileUpload正常工作的所有代码。 The problem I am having is when the fileupload is in the gridview it won't call the event that it calls while it is outside the gridview. 我遇到的问题是,当fileupload在gridview中时,它不在gridview之外时不会调用它所调用的事件。

Here is the code I have for my 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

So when the linkbutton is pressed in the gridview it enabled the panel that contains the file upload. 因此,当在gridview中按下linkbutton时,它启用了包含文件上载的面板。

Code for the OnUploadComplete event is : 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

All the code is doing is saving the file in a folder. 代码要做的就是将文件保存在文件夹中。 Also I have tried changing the ajaxfileupload to OnClientUploadComplete="AjaxFileUploadEvent" and it still does not call the event. 我也尝试将ajaxfileupload更改为OnClientUploadComplete="AjaxFileUploadEvent" ,但它仍然不调用该事件。 I just need to know how to make it call the correct event instead of just doing a postback. 我只需要知道如何调用正确的事件而不仅仅是回发。 Thanks 谢谢

if your web config do you have something like the following below.. 如果你的网络配置你有以下类似的东西..

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM