By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,901 Members | 1,459 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,901 IT Pros & Developers. It's quick & easy.

Reading file from Client instead of Server

P: n/a
SAL
Hello,

Is it possible to read a CSV from the Client, and bind my Datagrid to the
data in the CSV file without uploading the file to the Server first?

I have tried and in Debug mode on my workstation it works fine, but when I
publish the page on our DEV server it doesn't fine the CSV file from the
client.

Has anyone done this before? If so, how do I do it? I'm new to ASP.net so
if you have some sample code I can look at that would be great.

Thanks,

Oct 24 '06 #1
Share this Question
Share on Google+
12 Replies


P: n/a
I dont think this is possible. The only processing that can be done on
the client is through Javascript and Javascript cannot read from files.

Why are you trying to accomplish all of this on the client?

Jeff
SAL wrote:
Hello,

Is it possible to read a CSV from the Client, and bind my Datagrid to the
data in the CSV file without uploading the file to the Server first?

I have tried and in Debug mode on my workstation it works fine, but when I
publish the page on our DEV server it doesn't fine the CSV file from the
client.

Has anyone done this before? If so, how do I do it? I'm new to ASP.net so
if you have some sample code I can look at that would be great.

Thanks,
Oct 24 '06 #2

P: n/a
You can find a file on the client's file system if you use WSH (Windows
Scripting Host). You would need to set special security on each client
browser.

Asp.Net databinding is a pure server-side functionality. You can't do it on
client.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
"SAL" <SA*@discussions.microsoft.comwrote in message
news:31**********************************@microsof t.com...
Hello,

Is it possible to read a CSV from the Client, and bind my Datagrid to the
data in the CSV file without uploading the file to the Server first?

I have tried and in Debug mode on my workstation it works fine, but when I
publish the page on our DEV server it doesn't fine the CSV file from the
client.

Has anyone done this before? If so, how do I do it? I'm new to ASP.net
so
if you have some sample code I can look at that would be great.

Thanks,

Oct 24 '06 #3

P: n/a
SAL
Because I want to allow the user to make edits to the data if they have to
before I save the data to a SQL Server DB.

"Jeff" wrote:
I dont think this is possible. The only processing that can be done on
the client is through Javascript and Javascript cannot read from files.

Why are you trying to accomplish all of this on the client?

Jeff
SAL wrote:
Hello,

Is it possible to read a CSV from the Client, and bind my Datagrid to the
data in the CSV file without uploading the file to the Server first?

I have tried and in Debug mode on my workstation it works fine, but when I
publish the page on our DEV server it doesn't fine the CSV file from the
client.

Has anyone done this before? If so, how do I do it? I'm new to ASP.net so
if you have some sample code I can look at that would be great.

Thanks,

Oct 24 '06 #4

P: n/a
SAL
Currently I have a System.Web.UI.HtmlControls.HtmlInputFile control on my
Webform that allows the user to find their CSV file, and I read that CSV file
into a Data Table. I then send that Data Table in my Class back to my ASPX,
and store it in a Data View then bind my DataGrid to that Data View.

I thought this would work without uploading the file to the Server, because
I didn't want to manage these files on the Server when I was done with them.

"Eliyahu Goldin" wrote:
You can find a file on the client's file system if you use WSH (Windows
Scripting Host). You would need to set special security on each client
browser.

Asp.Net databinding is a pure server-side functionality. You can't do it on
client.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
"SAL" <SA*@discussions.microsoft.comwrote in message
news:31**********************************@microsof t.com...
Hello,

Is it possible to read a CSV from the Client, and bind my Datagrid to the
data in the CSV file without uploading the file to the Server first?

I have tried and in Debug mode on my workstation it works fine, but when I
publish the page on our DEV server it doesn't fine the CSV file from the
client.

Has anyone done this before? If so, how do I do it? I'm new to ASP.net
so
if you have some sample code I can look at that would be great.

Thanks,


Oct 24 '06 #5

P: n/a
Jay
Save your file in the database with an extra argument so it's not shown
by defailt (status var) or save the file on the server linked to the
client's IP address

SAL wrote:
Because I want to allow the user to make edits to the data if they have to
before I save the data to a SQL Server DB.
Oct 24 '06 #6

P: n/a
You can also upload the file to the server to do all that you want to
do with it and then delete it as soon as your finished using it or when
the session ends.

SAL wrote:
Currently I have a System.Web.UI.HtmlControls.HtmlInputFile control on my
Webform that allows the user to find their CSV file, and I read that CSV file
into a Data Table. I then send that Data Table in my Class back to my ASPX,
and store it in a Data View then bind my DataGrid to that Data View.

I thought this would work without uploading the file to the Server, because
I didn't want to manage these files on the Server when I was done with them.

"Eliyahu Goldin" wrote:
You can find a file on the client's file system if you use WSH (Windows
Scripting Host). You would need to set special security on each client
browser.

Asp.Net databinding is a pure server-side functionality. You can't do it on
client.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
"SAL" <SA*@discussions.microsoft.comwrote in message
news:31**********************************@microsof t.com...
Hello,
>
Is it possible to read a CSV from the Client, and bind my Datagrid to the
data in the CSV file without uploading the file to the Server first?
>
I have tried and in Debug mode on my workstation it works fine, but when I
publish the page on our DEV server it doesn't fine the CSV file from the
client.
>
Has anyone done this before? If so, how do I do it? I'm new to ASP.net
so
if you have some sample code I can look at that would be great.
>
Thanks,
>
Oct 24 '06 #7

P: n/a
SAL
Hi Jay,

How would I save the file on the server linked to the client's IP address?

I'm fairly new at C# and ASP.net, so if you have a code snippet I can look
at that would be great.

Would this file automatically be dispose of when the client existed their
browser or would I still need to manage this file and delete it when I was
done with it?

"Jay" wrote:
Save your file in the database with an extra argument so it's not shown
by defailt (status var) or save the file on the server linked to the
client's IP address

SAL wrote:
Because I want to allow the user to make edits to the data if they have to
before I save the data to a SQL Server DB.

Oct 24 '06 #8

P: n/a
What you describe sounds like it should work.

What exactly isn't working about it?

How are you converting the CSV to DataTable?

Here is an example of what you want to do using a CSV reader 3rd party
library (there are other ways..but you asked for source code example).

http://www.csvreader.com/csv_samples.php

Note that instead of saving to the database, you would send the data
table into your class as you describe in your post.

HTH.
SAL wrote:
Currently I have a System.Web.UI.HtmlControls.HtmlInputFile control on my
Webform that allows the user to find their CSV file, and I read that CSV file
into a Data Table. I then send that Data Table in my Class back to my ASPX,
and store it in a Data View then bind my DataGrid to that Data View.

I thought this would work without uploading the file to the Server, because
I didn't want to manage these files on the Server when I was done with them.

"Eliyahu Goldin" wrote:
You can find a file on the client's file system if you use WSH (Windows
Scripting Host). You would need to set special security on each client
browser.

Asp.Net databinding is a pure server-side functionality. You can't do it on
client.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
"SAL" <SA*@discussions.microsoft.comwrote in message
news:31**********************************@microsof t.com...
Hello,
>
Is it possible to read a CSV from the Client, and bind my Datagrid to the
data in the CSV file without uploading the file to the Server first?
>
I have tried and in Debug mode on my workstation it works fine, but when I
publish the page on our DEV server it doesn't fine the CSV file from the
client.
>
Has anyone done this before? If so, how do I do it? I'm new to ASP.net
so
if you have some sample code I can look at that would be great.
>
Thanks,
>
Oct 24 '06 #9

P: n/a
SAL
I am using the that snippet code you pointed me to in my Webform.

As for what exactly isn't working, it assume the file the user selected at
the client was uploaded to the server, and gives a general error message that
says something like the path to the file you specified doesn't exist.

I just assumed that if I read the CSV file from the Client into a Data
Table, that the Data Table reference with all it's data would have been
passed to the server, instead of trying to find the CSV file on the Server.

"xAvailx" wrote:
What you describe sounds like it should work.

What exactly isn't working about it?

How are you converting the CSV to DataTable?

Here is an example of what you want to do using a CSV reader 3rd party
library (there are other ways..but you asked for source code example).

http://www.csvreader.com/csv_samples.php

Note that instead of saving to the database, you would send the data
table into your class as you describe in your post.

HTH.
SAL wrote:
Currently I have a System.Web.UI.HtmlControls.HtmlInputFile control on my
Webform that allows the user to find their CSV file, and I read that CSV file
into a Data Table. I then send that Data Table in my Class back to my ASPX,
and store it in a Data View then bind my DataGrid to that Data View.

I thought this would work without uploading the file to the Server, because
I didn't want to manage these files on the Server when I was done with them.

"Eliyahu Goldin" wrote:
You can find a file on the client's file system if you use WSH (Windows
Scripting Host). You would need to set special security on each client
browser.
>
Asp.Net databinding is a pure server-side functionality. You can't do it on
client.
>
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
>
>
"SAL" <SA*@discussions.microsoft.comwrote in message
news:31**********************************@microsof t.com...
Hello,

Is it possible to read a CSV from the Client, and bind my Datagrid to the
data in the CSV file without uploading the file to the Server first?

I have tried and in Debug mode on my workstation it works fine, but when I
publish the page on our DEV server it doesn't fine the CSV file from the
client.

Has anyone done this before? If so, how do I do it? I'm new to ASP.net
so
if you have some sample code I can look at that would be great.

Thanks,

>
>
>

Oct 24 '06 #10

P: n/a
So, you are using THAT 3rd party library?

Can you post a simple program that demonstrates the problem and
indicate which line is causing the error with the exact error message?
(http://www.pobox.com/~skeet/csharp/complete.html)

It sounds like your problem is with uploading the file and not the CSV
file conversion.
SAL wrote:
I am using the that snippet code you pointed me to in my Webform.

As for what exactly isn't working, it assume the file the user selected at
the client was uploaded to the server, and gives a general error message that
says something like the path to the file you specified doesn't exist.

I just assumed that if I read the CSV file from the Client into a Data
Table, that the Data Table reference with all it's data would have been
passed to the server, instead of trying to find the CSV file on the Server.

"xAvailx" wrote:
What you describe sounds like it should work.

What exactly isn't working about it?

How are you converting the CSV to DataTable?

Here is an example of what you want to do using a CSV reader 3rd party
library (there are other ways..but you asked for source code example).

http://www.csvreader.com/csv_samples.php

Note that instead of saving to the database, you would send the data
table into your class as you describe in your post.

HTH.
SAL wrote:
Currently I have a System.Web.UI.HtmlControls.HtmlInputFile control on my
Webform that allows the user to find their CSV file, and I read that CSV file
into a Data Table. I then send that Data Table in my Class back to my ASPX,
and store it in a Data View then bind my DataGrid to that Data View.
>
I thought this would work without uploading the file to the Server, because
I didn't want to manage these files on the Server when I was done with them.
>
>
>
"Eliyahu Goldin" wrote:
>
You can find a file on the client's file system if you use WSH (Windows
Scripting Host). You would need to set special security on each client
browser.

Asp.Net databinding is a pure server-side functionality. You can't do it on
client.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


"SAL" <SA*@discussions.microsoft.comwrote in message
news:31**********************************@microsof t.com...
Hello,
>
Is it possible to read a CSV from the Client, and bind my Datagrid to the
data in the CSV file without uploading the file to the Server first?
>
I have tried and in Debug mode on my workstation it works fine, but when I
publish the page on our DEV server it doesn't fine the CSV file from the
client.
>
Has anyone done this before? If so, how do I do it? I'm new to ASP.net
so
if you have some sample code I can look at that would be great.
>
Thanks,
>

Oct 24 '06 #11

P: n/a
SAL
You are correct on both counts. I do not have a problem reading the file with
the 3rd party CSVReader.

My Webform works fine IF I save the file to the Server for the CSVReader to
work.

I want to read the CSV file at the Client, load the Data Table from the CSV
file at the Client, then pass the Data Table back to my Webform from my
library class. After which, store this Data Table reference in my a Data
view and bind that Data View to my Data Grid.

From the post I've read, it sounds like I can't do this. It sounds like I
have not choice to to save the file server, then delete it from the server
when I'm done with it which is what I was trying to avoid.

"xAvailx" wrote:
So, you are using THAT 3rd party library?

Can you post a simple program that demonstrates the problem and
indicate which line is causing the error with the exact error message?
(http://www.pobox.com/~skeet/csharp/complete.html)

It sounds like your problem is with uploading the file and not the CSV
file conversion.
SAL wrote:
I am using the that snippet code you pointed me to in my Webform.

As for what exactly isn't working, it assume the file the user selected at
the client was uploaded to the server, and gives a general error message that
says something like the path to the file you specified doesn't exist.

I just assumed that if I read the CSV file from the Client into a Data
Table, that the Data Table reference with all it's data would have been
passed to the server, instead of trying to find the CSV file on the Server.

"xAvailx" wrote:
What you describe sounds like it should work.
>
What exactly isn't working about it?
>
How are you converting the CSV to DataTable?
>
Here is an example of what you want to do using a CSV reader 3rd party
library (there are other ways..but you asked for source code example).
>
http://www.csvreader.com/csv_samples.php
>
Note that instead of saving to the database, you would send the data
table into your class as you describe in your post.
>
HTH.
>
>
SAL wrote:
Currently I have a System.Web.UI.HtmlControls.HtmlInputFile control on my
Webform that allows the user to find their CSV file, and I read that CSV file
into a Data Table. I then send that Data Table in my Class back to my ASPX,
and store it in a Data View then bind my DataGrid to that Data View.

I thought this would work without uploading the file to the Server, because
I didn't want to manage these files on the Server when I was done with them.



"Eliyahu Goldin" wrote:

You can find a file on the client's file system if you use WSH (Windows
Scripting Host). You would need to set special security on each client
browser.
>
Asp.Net databinding is a pure server-side functionality. You can't do it on
client.
>
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
>
>
"SAL" <SA*@discussions.microsoft.comwrote in message
news:31**********************************@microsof t.com...
Hello,

Is it possible to read a CSV from the Client, and bind my Datagrid to the
data in the CSV file without uploading the file to the Server first?

I have tried and in Debug mode on my workstation it works fine, but when I
publish the page on our DEV server it doesn't fine the CSV file from the
client.

Has anyone done this before? If so, how do I do it? I'm new to ASP.net
so
if you have some sample code I can look at that would be great.

Thanks,

>
>
>
>
>

Oct 24 '06 #12

P: n/a
>I want to read the CSV file at the Client, load the Data Table from the CSV
file at the Client, then pass the Data Table back to my Webform from my

library class. <<

I don't think this is possible in the way you describe, but that
doesn't mean you have to store on server or database.

When you upload the file, it is stored in the InputStream property of
the HttpPostedFile object. At that point, you can convert to the
datatable or manipulate the stream as needed in your class or persist
for further manipulation (probably in session or view state).

The example I was pointing at is "Upload CSV file to SQL Server using
FileUpload, CsvDataReader, and SqlBulkCopy in .Net 2.0"

I don't have that library, but based on the example code they have, the
(pseudo) code would look something like this..

protected void uploadButton_Click(object sender, EventArgs e)
{
using (CsvDataReader uploadedFile = new
CsvDataReader(fileUpload.PostedFile.InputStream, Encoding.Default))
{
DataTable myDataTable = new DataTable();

myDataTable.Load(uploadedFile.ReadToEnd(True));

YourClass anInstanceOfYourClass = YourClass.New(myDataTable);

//Manipulate your class or persist...
anInstanceOfYourClass.DoWhatever();

}
}

You are still going to have to persist your class (session, view state,
or somewhere...) if you are to further manipulate in between page
calls.

I don't know your specific requirements, but if all you are worried
about is "maintaining" the uploaded files, and the above doesn't work
in your scenario (it is worth noting that it will probably consume a
lot of memory if you are going to persist in session), then you can
just store the file in a datastore and create a scheduled job to clean
up the data. You would probably use the session id to tie back to the
session that uploaded the file.

HTH.

SAL wrote:
You are correct on both counts. I do not have a problem reading the file with
the 3rd party CSVReader.

My Webform works fine IF I save the file to the Server for the CSVReader to
work.

I want to read the CSV file at the Client, load the Data Table from the CSV
file at the Client, then pass the Data Table back to my Webform from my
library class. After which, store this Data Table reference in my a Data
view and bind that Data View to my Data Grid.

From the post I've read, it sounds like I can't do this. It sounds like I
have not choice to to save the file server, then delete it from the server
when I'm done with it which is what I was trying to avoid.

"xAvailx" wrote:
So, you are using THAT 3rd party library?

Can you post a simple program that demonstrates the problem and
indicate which line is causing the error with the exact error message?
(http://www.pobox.com/~skeet/csharp/complete.html)

It sounds like your problem is with uploading the file and not the CSV
file conversion.
SAL wrote:
I am using the that snippet code you pointed me to in my Webform.
>
As for what exactly isn't working, it assume the file the user selected at
the client was uploaded to the server, and gives a general error message that
says something like the path to the file you specified doesn't exist.
>
I just assumed that if I read the CSV file from the Client into a Data
Table, that the Data Table reference with all it's data would have been
passed to the server, instead of trying to find the CSV file on the Server.
>
"xAvailx" wrote:
>
What you describe sounds like it should work.

What exactly isn't working about it?

How are you converting the CSV to DataTable?

Here is an example of what you want to do using a CSV reader 3rd party
library (there are other ways..but you asked for source code example).

http://www.csvreader.com/csv_samples.php

Note that instead of saving to the database, you would send the data
table into your class as you describe in your post.

HTH.


SAL wrote:
Currently I have a System.Web.UI.HtmlControls.HtmlInputFile control on my
Webform that allows the user to find their CSV file, and I read that CSV file
into a Data Table. I then send that Data Table in my Class back to my ASPX,
and store it in a Data View then bind my DataGrid to that Data View.
>
I thought this would work without uploading the file to the Server, because
I didn't want to manage these files on the Server when I was done with them.
>
>
>
"Eliyahu Goldin" wrote:
>
You can find a file on the client's file system if you use WSH (Windows
Scripting Host). You would need to set special security on each client
browser.

Asp.Net databinding is a pure server-side functionality. You can't do it on
client.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


"SAL" <SA*@discussions.microsoft.comwrote in message
news:31**********************************@microsof t.com...
Hello,
>
Is it possible to read a CSV from the Client, and bind my Datagrid to the
data in the CSV file without uploading the file to the Server first?
>
I have tried and in Debug mode on my workstation it works fine, but when I
publish the page on our DEV server it doesn't fine the CSV file from the
client.
>
Has anyone done this before? If so, how do I do it? I'm new to ASP.net
so
if you have some sample code I can look at that would be great.
>
Thanks,
>



Oct 24 '06 #13

This discussion thread is closed

Replies have been disabled for this discussion.