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 6887661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:54:43+00:00 2026-05-27T05:54:43+00:00

i have default.aspx page and one user control. usercontrol is having following code for

  • 0

i have default.aspx page and one user control.
usercontrol is having following code for multiple file uploads.
now the problem is when i add a file for upload that current context file is not giving me any value it is still zero i guess because it is rendering from user control.

what should i do?

My Usercontrol UPLOAD.ASCX

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="FileUpload.ascx.cs" Inherits="FileUpload" %>
<script type="text/javascript" src="_scripts/jquery-1.4.1.min.js"></script>    
<script type="text/javascript">
    var i = 1;
    $(document).ready(function () {
        $("#addfile").click(function () {
            $("#dvfiles").append("<input name=" + i + "fu type=file /><a href=#>remove</a><br>");
            i++;
        });

        $("#dvfiles a").live('click', function () {
            $(this).prev("input[type=file]").remove();
            $(this).remove();
        });
    });

    $(document).submit(function () {
        var flag = true;
        $("#dvfiles input[type=file]").each(function () {
            if ($(this).val() == "") {
                $(this).css("background", "Red");
                flag = false;
            }
        });
        return flag;
    });        
</script>

<div id="Fileuploader">
<a href="#" id="addfile">Attach a file..</a><br />
<asp:Label ID="lblMessage" runat="server"></asp:Label><br />
<asp:Button ID="btnUpload" runat="server" Text="Upload"
    onclick="btnUpload_Click" />
</div>

UPLOAD.ASCX.CS

protected void btnUpload_Click(object sender, EventArgs e)
{
    try
    {
        HttpFileCollection filecolln = Request.Files; 
        //here i don't get values of current files.
      // this is zero. because of this following if condition failed 
       //please help here
        if (filecolln.Count > 0)
        {
            for (int i = 0; i < filecolln.Count; i++)
            {
                HttpPostedFile file = filecolln[i];
                if (file.ContentLength > 0)
                {
                    file.SaveAs(ConfigurationManager.AppSettings["FilePath"] + System.IO.Path.GetFileName(file.FileName));
                }
            }
            lblMessage.Text = "Uploaded Successfully!";
        }
        else
        {
            lblMessage.Text = "No files selected!";
        }

    }
    catch (Exception ex)
    {
        lblMessage.Text = ex.Message;
    }
}

Default.aspx code

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"    
    Inherits="_Default" %>
    <%@ Register TagPrefix="ucFileuploader" tagName="Fileuploader" src="FileUpload.ascx"    %> 

   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org /TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <ucFileuploader:Fileuploader ID="Fileuploder" runat="server" />
    </div>
    </form>
</body>
</html>
  • 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-27T05:54:43+00:00Added an answer on May 27, 2026 at 5:54 am

    The problem is that you are using javascript an id names.

    so when you have control with id addfile in .aspx it is rendered as is,
    but when you have control with id addfile in user control with id Fileuploader,
    than the rendered id is Fileuploader_addfile,
    so change id name in java script with the proper id.

    To chechk what is name of rendered id, open page in browser, open source of the page and find you element and copy id into java script.
    Change all ids in java script with rendered id names.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following webform: <%@ Page Language=C# AutoEventWireup=true CodeBehind=Default.aspx.cs Inherits=TestWebApp.Default %> <!DOCTYPE html
I am having an aspx page where I have added one asp.net text box
I have Default.aspx page, which inherits from BasePage.cs, which inherits from System.Web.UI.Page. BasePage is
I have an ASPX Page: <%@ Page Language=C# MasterPageFile=~/site.Master AutoEventWireup=true CodeBehind=Default.aspx.cs Inherits=myProject.Presentation.Web.Default src=Default.aspx.cs %>
In my aspx page I have a tr which is set visible=false by default.
In my .aspx page I have; <%@ Page Language=VB AutoEventWireup=false CodeFile=Default.aspx.vb Inherits=_Default AspCompat=True %>
I have configured my default page to be say abcd.aspx and is under ~/View//abcd.aspx
In the filesystem I have /file.aspx /directory/default.aspx I want to configure IIS so that
I have two aspx page on my application. From the first one, lets say
I have an aspx page with one form submitting to itself. In the form

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.