Get the filename in aspx page?

Jun 10, 2009 at 1:28 PM

How would you go about to get the uploaded file(s) name(s) returned through the aspx page? There was a previous post on something similar to this, but no answer, hoping for one this time, cause i really need it to send into my database.

 

Thanks!

Coordinator
Jun 10, 2009 at 3:18 PM
Are you using an aspx page to upload to or a HTTPHander? And is that the aspx page you are talking about, or the one that hosts the silverlight? If it is the upload page the you can get the file and filename in the FileUploadCompleted event of the FileUploadProcess object (see the example project).
FileUploadProcess fileUpload = new FileUploadProcess();
fileUpload.FileUploadCompleted += new FileUploadCompletedEvent(fileUpload_FileUploadCompleted);

void fileUpload_FileUploadCompleted(object sender, FileUploadCompletedEventArgs args)
{
string fileName = args.FileName;
}


Darick


From: [email removed]
To: [email removed]
Date: Wed, 10 Jun 2009 05:28:20 -0700
Subject: Get the filename in aspx page? [SilverlightFileUpld:59052]

From: Belial
How would you go about to get the uploaded file(s) name(s) returned through the aspx page? There was a previous post on something similar to this, but no answer, hoping for one this time, cause i really need it to send into my database.

Thanks!


Lauren found her dream laptop. Find the PC that’s right for you.
Jun 10, 2009 at 3:47 PM

My project looks like this: I have copied the .xap file (FileUpload.xap) and the generic handler (FileUpload.ashx), along with the fileuploadprocess class (because the HTTPHandler uses that class) into my project.

Then I have an aspx page (Default.aspx) that has a Silverlight control, according to the FileUploadTestPage.aspx in the example project:

<asp:Silverlight ID="Xaml1" runat="server" Source="~/Information/Presentations/UserControls/ClientBin/FileUpload.xap"
                Width="320px" Height="200px" MinimumVersion="2.0.31005.0"
                InitParameters="UploadPage=UserControls/FileUpload.ashx,Filter=Movies (*.avi;*.mpg;*.wmv;*.mpeg;*.mov)|*.avi;*.mpg;*.wmv;*.mpeg;*.mov" />

As you can see I'm not using the MultiFileUploadControl, but i looked through it, and didn't find any obvious solution that would make it better for me to use that instead of the Silverlight control for this purpose.

So I want to get the filename from the uploaded file returned to Default.aspx.cs (from the HTTPHandler??), so I can insert it into my database. I'm sure there is a way to return it from the HTTPHandler (ashx), but I have no idea how to do that, if it's possible a small example would be greatly appreciated.

 

And when you say the aspx page that hosts the silverlight or the upload page? what is the difference? in the example which page is the upload page and which is the silverlight host?

Coordinator
Jun 10, 2009 at 3:58 PM
Ok, the upload page I was referring to is the generic handler (FileUpload.ashx). That is where you would insert it into the database, not Default.aspx.cs. To me it doesn't make sense to do it in Default.aspx.cs. But if you really had to, you can put the filename into a session variable, just make sure the HTTPHandler inherits IRequiresSessionState.

Darick


From: [email removed]
To: [email removed]
Date: Wed, 10 Jun 2009 07:47:59 -0700
Subject: Re: Get the filename in aspx page? [SilverlightFileUpld:59052]

From: Belial
My project looks like this: I have copied the .xap file (FileUpload.xap) and the generic handler (FileUpload.ashx), along with the fileuploadprocess class (because the HTTPHandler uses that class) into my project.
Then I have an aspx page (Default.aspx) that has a Silverlight control, according to the FileUploadTestPage.aspx in the example project:
<asp:Silverlight ID="Xaml1" runat="server" Source="~/Information/Presentations/UserControls/ClientBin/FileUpload.xap"
Width="320px" Height="200px" MinimumVersion="2.0.31005.0"
InitParameters="UploadPage=UserControls/FileUpload.ashx,Filter=Movies (*.avi;*.mpg;*.wmv;*.mpeg;*.mov)|*.avi;*.mpg;*.wmv;*.mpeg;*.mov" />
As you can see I'm not using the MultiFileUploadControl, but i looked through it, and didn't find any obvious solution that would make it better for me to use that instead of the Silverlight control for this purpose.
So I want to get the filename from the uploaded file returned to Default.aspx.cs (from the HTTPHandler??), so I can insert it into my database. I'm sure there is a way to return it from the HTTPHandler (ashx), but I have no idea how to do that, if it's possible a small example would be greatly appreciated.

And when you say the aspx page that hosts the silverlight or the upload page? what is the difference? in the example which page is the upload page and which is the silverlight host?


Windows Live™: Keep your life in sync. Check it out.
Jun 11, 2009 at 1:06 PM

Okay, thank you for your answers. I also should mention that I have to add some values from textboxes when inserting into the database, so if I were to insert from the generic handler I have to get these values some way, but since there is no button event in the multifileuploadcontrol, since silverlight and the rest is separated, I have decided that I will rewrite/expand parts of the logic to match my needs ;) Unless you have some idea how to get the values from the textboxes, I  thank you very much for your time and for making an awesome upload control!

Aug 6, 2009 at 6:10 AM
Belial wrote:

Okay, thank you for your answers. I also should mention that I have to add some values from textboxes when inserting into the database, so if I were to insert from the generic handler I have to get these values some way, but since there is no button event in the multifileuploadcontrol, since silverlight and the rest is separated, I have decided that I will rewrite/expand parts of the logic to match my needs ;) Unless you have some idea how to get the values from the textboxes, I  thank you very much for your time and for making an awesome upload control!

Hi, i wonder if you succeeded in getting values from the textboxes and inserting the filename of the file uploaded into the database. Did it work? Some example would be very much appreciated.

See I also have a problem with getting the list of file uploaded into the database. I added the control into silverlight project by referencing the "DC.FileUpload.dll" and then set up the UploadPage properties to the .ashx file, just like this:

xmlns:my="clr-namespace:DC.FileUpload;assembly=DC.FileUpload"

. . . . . .

<my:FileUploadControl x:Name="flUpload" Width="Auto" Height="Auto" UploadUrl="http://localhost:2447/FileUpload.ashx" HorizontalAlignment="Stretch"/>

Using that code, this upload control works just fine! But I still can't figure out how to attach it into my database.. Can you share some of the information please? Thanks for your kindness.

Aug 22, 2009 at 11:08 PM
Hi, I never took the time to finish what i started, but if I do, I'll get back to you

2009/8/6 ume <notifications@codeplex.com>

From: ume

Belial wrote:

Okay, thank you for your answers. I also should mention that I have to add some values from textboxes when inserting into the database, so if I were to insert from the generic handler I have to get these values some way, but since there is no button event in the multifileuploadcontrol, since silverlight and the rest is separated, I have decided that I will rewrite/expand parts of the logic to match my needs ;) Unless you have some idea how to get the values from the textboxes, I  thank you very much for your time and for making an awesome upload control!

Hi, i wonder if you succeeded in getting values from the textboxes and inserting the filename of the file uploaded into the database. Did it work? Some example would be very much appreciated.

See I also have a problem with getting the list of file uploaded into the database. I added the control into silverlight project by referencing the "DC.FileUpload.dll" and then set up the UploadPage properties to the .ashx file, just like this:

xmlns:my="clr-namespace:DC.FileUpload;assembly=DC.FileUpload"

. . . . . .

<my:FileUploadControl x:Name="flUpload" Width="Auto" Height="Auto" UploadUrl="http://localhost:2447/FileUpload.ashx" HorizontalAlignment="Stretch"/>

Using that code, this upload control works just fine! But I still can't figure out how to attach it into my database.. Can you share some of the information please? Thanks for your kindness.

Read the full discussion online.

To add a post to this discussion, reply to this email (SilverlightFileUpld@discussions.codeplex.com)

To start a new discussion for this project, email SilverlightFileUpld@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com




--
Christopher Nyström
Torggatan 28b
74531 ENKÖPING

Mobil: 073-576 00 41
Hem:  0171-101406
Sep 4, 2009 at 4:01 AM

Hi Darrick,

Im using your project and i cant seem to put it inside my asp.net page. i did this on my aspx page for my asp.net but it doesnt seem to load.

<%@ Page Title="" Language="C#" MasterPageFile="~/Student/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Student_Default" %>
<%@ Register Assembly="System.Web.Silverlight" Namespace="System.Web.UI.SilverlightControls"
TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

<form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <asp:Silverlight ID="Silverlight1" Runat="Server"
                 Source="~/ClientBin/FileUpload.xap"
                 Version="2.0"
                 Width="932px"
                 Height="677px" />

 

Ive added the .xap file inside the ClientBin but the file upload program just wont start. its stucked at 100%

and one more thing,

How can I retrieve and display the filenames that has been uploaded, on a new aspx page?