Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6673677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:39:19+00:00 2026-05-26T03:39:19+00:00

I have an AsynchFileUpload on my page and for some reason when I try

  • 0

I have an AsynchFileUpload on my page and for some reason when I try to use it to save the file to the server it falls.

The control will allow me to select a file locally and it displays the local file path in its text box, BUT when I then click a button on my page which I am going to be using to submit all details then upload the page everything goes wrong and I get a Null Ref Exception from the AsynchFileUploader.

My uploader is fairly basic and looks like:

   <cc1:AsyncFileUpload runat="server" 
                                  ID="AsyncFileUpload2" 
                                  Enabled="true" 
                                  Visible="true"/>

The uploader is within a tab container / tab panel / content template / update panel with the update mode set to conditional. Im fairly new to ASP so im not sure if the controls containing the uploader could be causing the problem.

Then in my code i have:

 Dim filename As String = System.IO.Path.GetFileName(AsyncFileUpload2.FileName)

        Dim comments As String = SpellTextBox1.Text


        Dim NewDirectory As String = Server.MapPath("~/Helpdesk/UploadedFiles/" + TicketID.ToString())

        Try



           'Check if directory exists
           If Not Directory.Exists(NewDirectory) Then

              ' Create the directory.
              Directory.CreateDirectory(NewDirectory)

           End If

           AsyncFileUpload2.SaveAs(NewDirectory + "\" + filename)

        Catch _ex As IOException
           'Silently error for now
           'Response.Write(_ex.Message)

        End Try

It seems that the filename is being lost somewhere after the button is clicked, or just never stored

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T03:39:20+00:00Added an answer on May 26, 2026 at 3:39 am

    Solved by doing:

    Private Sub AsyncFileUpload1_UploadedComplete(ByVal sender As Object, ByVal e As AjaxControlToolkit.AsyncFileUploadEventArgs) Handles AsyncFileUpload1.UploadedComplete
          If e.State = AjaxControlToolkit.AsyncFileUploadState.Success Then
    
             Dim ticketID As String = Request.QueryString("ID").ToString()
             Dim filename As String = e.FileName
    
             Dim temp() As String = filename.Split("\")
             filename = temp(temp.Length - 1)
    
    
             Dim NewDirectory As String = Server.MapPath("~/Helpdesk/UploadedFiles/" + ticketID + "/")
    
             'Check if directory exists
             If Not Directory.Exists(NewDirectory) Then
    
                ' Create the directory.
                Directory.CreateDirectory(NewDirectory)
    
             End If
    
             ' Save the file on the server
             AsyncFileUpload1.SaveAs(NewDirectory + filename)
    
             'Now put the file details in the database
             dbSaveFile(ticketID, filename, "UploadedFiles/" + ticketID + "/" + filename, "")
    
             'Raise some kind of notification informing the user that this has been sucessfull
    
    
    
             'And rebind the control
             ' Get Event Details and populate text fields
             Dim dsFiles As DataSet = dbGetFiles(ticketID)
    
             If dsFiles Is Nothing Then
                ' No need to error here if we have no files
             Else
                gvFiles.DataSource = dbGetFiles(ticketID)
                gvFiles.DataBind()
    
             End If
    
          Else
             ' Do nothing
          End If
       End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a asp:FileUpload control in my page. The default file size is 4MB.
I have a file upload page with an AsyncFileUpload control. When the user browses
I have an asyncfileupload control that I'm using from the ajaxcontroltoolkit. On the file
I have an asyncfileupload control inside an update panel. The file succesfully upload and
I have used AsyncFileUpload AJAX control to upload a file to a column in
have 2 questions : A computer with 32-bit address uses 2-level page table (9
I am using ajax toolkit asyncFileUpload control I had problem that my server side
Have some code: using (var ctx = new testDataContext()) { var options = new
Have a simple contact us XPage created. Have server side validation in place that
I have Async File Upload <cc1:AsyncFileUpload ID=AsyncFileUpload2 EnableViewState=true Width=400 UploaderStyle=Modern OnClientUploadComplete=showDiv OnUploadedComplete=AsyncFileUpload1_UploadedComplete ClientIDMode=AutoID runat=server

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.