Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. FileUpload doesnt upload

FileUpload doesnt upload

Scheduled Pinned Locked Moved ASP.NET
csharpsysadmin
6 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    Wouter Coinless
    wrote on last edited by
    #1

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="FileControl.ascx.cs" Inherits="Administration_Controls_FileControl" %>
    <div style="width: 100%; height: 50px;">
    <asp:FileUpload ID="FileUpload1" runat="server" />
    <asp:Button ID="test" runat="server" OnClick="test_click" />
    </div>

    protected void test_click(object sender, EventArgs e)
    {
    if (FileUpload1.HasFile)
    {

    }
    

    }

    I have this code, but i keep getting HasFile = false .. Anyone sees what im doing wrong.. I really dont see it. Thanks. Wouter

    A 1 Reply Last reply
    0
    • W Wouter Coinless

      <%@ Control Language="C#" AutoEventWireup="true" CodeFile="FileControl.ascx.cs" Inherits="Administration_Controls_FileControl" %>
      <div style="width: 100%; height: 50px;">
      <asp:FileUpload ID="FileUpload1" runat="server" />
      <asp:Button ID="test" runat="server" OnClick="test_click" />
      </div>

      protected void test_click(object sender, EventArgs e)
      {
      if (FileUpload1.HasFile)
      {

      }
      

      }

      I have this code, but i keep getting HasFile = false .. Anyone sees what im doing wrong.. I really dont see it. Thanks. Wouter

      A Offline
      A Offline
      Abhishek Sur
      wrote on last edited by
      #2

      Are you using this fileupload control inside UpdatePanel. It will not work inside an UpdatePanel, you need to forcefully postback using

      <Triggers>
      <asp:PostBackTrigger ControlID="test" >
      </Triggers>

      :rose:

      Abhishek Sur


      My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB

      **Don't forget to click "Good Answer" if you like to.

      W 1 Reply Last reply
      0
      • A Abhishek Sur

        Are you using this fileupload control inside UpdatePanel. It will not work inside an UpdatePanel, you need to forcefully postback using

        <Triggers>
        <asp:PostBackTrigger ControlID="test" >
        </Triggers>

        :rose:

        Abhishek Sur


        My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB

        **Don't forget to click "Good Answer" if you like to.

        W Offline
        W Offline
        Wouter Coinless
        wrote on last edited by
        #3

        Ok thanks , i posted my usercontrolid in the trigger, now it works :) Thanks!

        A 1 Reply Last reply
        0
        • W Wouter Coinless

          Ok thanks , i posted my usercontrolid in the trigger, now it works :) Thanks!

          A Offline
          A Offline
          Abhishek Sur
          wrote on last edited by
          #4

          Oh, the button is within a Panel. Use this Solution then :

          ScriptManager scr = ScriptManager.GetCurrent(this.Page);
          if (scr != null)
          {
          scr.RegisterPostBackControl(this.mycontrol.FindControl("test"));
          }

          Place this script inside the Page_Load section. Now click on the Button test and see if the Onclick event inside the Usercontrol gets fired with file in the FileUpload control. :-D :-D

          Abhishek Sur


          My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB

          **Don't forget to click "Good Answer" if you like to.

          W 1 Reply Last reply
          0
          • A Abhishek Sur

            Oh, the button is within a Panel. Use this Solution then :

            ScriptManager scr = ScriptManager.GetCurrent(this.Page);
            if (scr != null)
            {
            scr.RegisterPostBackControl(this.mycontrol.FindControl("test"));
            }

            Place this script inside the Page_Load section. Now click on the Button test and see if the Onclick event inside the Usercontrol gets fired with file in the FileUpload control. :-D :-D

            Abhishek Sur


            My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB

            **Don't forget to click "Good Answer" if you like to.

            W Offline
            W Offline
            Wouter Coinless
            wrote on last edited by
            #5

            Thanks man! Works great!

            A 1 Reply Last reply
            0
            • W Wouter Coinless

              Thanks man! Works great!

              A Offline
              A Offline
              Abhishek Sur
              wrote on last edited by
              #6

              Most welcome. Dont forget to click "Good Answer" , if it really helped you. :)

              Abhishek Sur


              My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB

              **Don't forget to click "Good Answer" if you like to.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups