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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T01:18:21+00:00 2026-06-19T01:18:21+00:00

I have a very simple ASP.NET page that uploads an Excel workbook, then processes

  • 0

I have a very simple ASP.NET page that uploads an Excel workbook, then processes it. It uses AJAXFILEUPLOAD from the AJAX toolkit on ASP.NET… Here’s the markup:

<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
CodeBehind="ImportWorkbook.aspx.cs" Inherits="Timesheet.ImportWorkbook" %>

<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="HeaderContentPlaceHolder">
<h1 class="topContent">
    Upload CPAS Timesheet Workbooks
</h1>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="RightContentPlaceHolder" runat="server">
<br />
<br />
<asp:HiddenField ID="tbTSID" runat="server" />
<asp:HiddenField ID="tbWorkbookPath" runat="server" />
<ajaxToolkit:AjaxFileUpload ID="AjaxFileUpload1" runat="server" AllowedFileTypes="xls,xlsx,xlsm"
    CssClass="dropdown" MaximumNumberOfFiles="1" OnUploadComplete="AjaxFileUpload1_UploadComplete" />
<br />
<br />
<asp:Panel ID="ProcessChoices" runat="server" >
    <br />
    <br />
    <p>
        Select how you want this workbook processed:</p>
    <br />
    <asp:RadioButtonList ID="rbChoices" runat="server" BorderStyle="Groove" BorderWidth="2px"
        BorderColor="Black" BackColor="Teal" Font-Names="Tahoma" Font-Size="10pt" ForeColor="White"
        Width="40%">
        <asp:ListItem Value="True" Selected="True">&nbsp Replace ALL Items in the Timesheet</asp:ListItem>
        <asp:ListItem Value="False">&nbsp Add Items from this Workbook to the Existing Timesheet Items</asp:ListItem>
    </asp:RadioButtonList>
    <br />
    <br />
    <asp:Button ID="btnValidate" runat="server" Text="Validate and Process" 
        BackColor="#B92217" ForeColor="White" BorderColor="#7C1810" 
        BorderStyle="Groove" Font-Names="Tahoma" onclick="btnValidate_Click" />
</asp:Panel>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="BottomSpanContentPlaceHolder" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
</asp:Content>

The master page and css pages are trivial, formatting only.

Here’s the codebehind:

 using System;
using System.IO;
using TimesheetUtilites;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AjaxControlToolkit;

    namespace Timesheet
    {

    public partial class ImportWorkbook : System.Web.UI.Page
    {
        private const string HDriveLocation= "H:\\mtv\\secure\\Construction\\Access\\CPAS WorkArea\\TimesheetUploads\\";
        private string strWorkbookPath;    
        private int currTSID;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.QueryString["ID"] != null)
                {
                    tbTSID.Value = Request.QueryString["ID"];            // Storing the Timesheet ID in a hidden Textbox                    
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(tbWorkbookPath.Value))
                {
                    ProcessChoices.Enabled = true;
                }
            }
            int.TryParse(tbTSID.Value, out currTSID);
            strWorkbookPath = tbWorkbookPath.Value;
        }
        protected void AjaxFileUpload1_UploadComplete(object sender, AjaxFileUploadEventArgs e)
        {
            strWorkbookPath = HDriveLocation + Path.GetFileName(e.FileName);
            tbWorkbookPath.Value = strWorkbookPath;
            AjaxFileUpload1.SaveAs(strWorkbookPath);
            ProcessChoices.Enabled = true;
        }

        protected void btnValidate_Click(object sender, EventArgs e)
        {
            bool processOption;
            bool.TryParse(rbChoices.SelectedValue, out processOption);
            strWorkbookPath = tbWorkbookPath.Value;
            TimesheetUtilites.ImportTimesheet imp = new ImportTimesheet(currTSID, strWorkbookPath, processOption);       
        }
    }
}

My issue is simple. Although the event handler “AjaxFileUpload1_UploadComplete” works fine, and uploads the file in an instant, when I fire the “btnValidate_Click” event, the “tbWorkbookPath.Value” has become an empty string, and the “ProcessChoices.Enabled” propety doesn’t change. Needless to say, the “Upload Complete” event handler is the only opportunity I have to capture this file path, so I’m at a loss what I’m doing wrong.

I posted on ASP.NET and go NO answers. Can anyone give me an idea where to start?

  • 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-06-19T01:18:23+00:00Added an answer on June 19, 2026 at 1:18 am

    This is information you should be storing in your page’s ViewState so that it persists between postbacks and resets on page initialization. Change your private string member to something like the following:

    private string strWorkbookPath {
        get {
            return this.ViewState["strWorkbookPath"];
        }
        set {
            this.ViewState["strWorkbookPath"] = value;
        }
    }
    

    If you need a primer on what the ViewState is, check out this article on MSDN: Saving Web Forms Page Values Using View State. It’s a bit dated but still communicates the basics of how ViewState operates currently.

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

Sidebar

Related Questions

I have a very simple CRUD asp.net-mvc site that uses nhibernate to interface with
I have a very simple ASP.Net MVC Application that I have produced from an
I have a very simple ASP.Net page that acts as a front end for
We have a very simple ASP.Net page for uploading a file to our webserver.
I have an ASP.Net MVC Page with a very simple form on it: One
I am trying to create a very simple ASP.NET page that allows a user
So, I'm making an ASP.NET page in C#. I have a very simple form
I'm trying to make a very simple asp.net page that binds a GridView using
I have a very simple ASP.NET MVC site which displays images from the database.
I have a very simple page built in asp.net (.NET Framework 4) which has

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.