You must Sign In to post a response.
  • Category: ASP.NET

    FileUpload and updatepanel

    My FileUpload is in updatepanel i am not able to find the file in fileupload in code behind.

    i Know that if we keep postback trigger to the button it is possible but my file upload is in thirdtab
    if full page gets refresh it is going to first tab and the file uploads present in first tab are also going .

    I dont want to use postbacktrigger .Can any one give the solution
  • #761453
    Hello K.shilpa,

    Share your code with us so that we can provide you the exact solution based on your requirement.

    You can upload file by using this code also :

    <form id="form1" runat="server" enctype="multipart/form-data">
    <input type="file" id="myFile" name="myFile" />
    <asp:Button runat="server" ID="btnUpload" OnClick="btnUploadClick" Text="Upload" />
    </form>


    protected void btnUploadClick(object sender, EventArgs e)
    {
    HttpPostedFile file = Request.Files["myFile"];

    //check file was submitted
    if (file != null && file.ContentLength > 0)
    {
    string fname = Path.GetFileName(file.FileName);
    file.SaveAs(Server.MapPath(Path.Combine("~/App_Data/", fname)));
    }
    }


    Hope this will help you.

    Regards,
    Nirav Lalan
    DNS Gold Member
    "Failure is the path of least persistence"

  • #761457
    no the code is not working .

    file is coming as null. in update panel it wont work.
    can i get some otherr solution

  • #761462
    Can you try the following

    Request.Form["myFile"];

    By Nathan
    Direction is important than speed

  • #761467
    no not working cannot convert string to system.web.httppostedfile

  • #761471
    Hi

    Check your previous post same question this

    http://www.dotnetspider.com/forum/342390-Update-panel-and-fileupload.aspx

    Do one thing Remove Update Panel while using Fileupload control then only we can find uploaded file.

    Can you share your code then participants quickly solve your issue.

    Name : Dotnet Developer-2015
    Email Id :kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.


Sign In to post your comments