473,385 Members | 1,736 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

q; what is wrong with this code?

private void DownloadFile(string fName)
{
string msg="download done";

/*
System.IO.fInfo fInfo = new System.IO.fInfo(fName);
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" +
fInfo.Name);
Response.AddHeader("Content-Length", fInfo.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.WriteFile(fInfo.FullName);
*/

this.myLabel.ForeColor=System.Drawing.Color.Red;
this.myLabel.Text=msg;
}

When I remove commented section, this method does not show the message in
myLabel on my page, where is the problem?
Sep 23 '06 #1
5 1243
The problem is that you're not sending an HTML document to the client. You
are sending a binary file.

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com

A watched clock never boils.

"JIM.H." <JI**@discussions.microsoft.comwrote in message
news:84**********************************@microsof t.com...
private void DownloadFile(string fName)
{
string msg="download done";

/*
System.IO.fInfo fInfo = new System.IO.fInfo(fName);
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" +
fInfo.Name);
Response.AddHeader("Content-Length", fInfo.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.WriteFile(fInfo.FullName);
*/

this.myLabel.ForeColor=System.Drawing.Color.Red;
this.myLabel.Text=msg;
}

When I remove commented section, this method does not show the message in
myLabel on my page, where is the problem?


Sep 24 '06 #2
Thanks Kevin, I am trying to make sure I am getting open/save dialog box, any
solution for me?

"Kevin Spencer" wrote:
The problem is that you're not sending an HTML document to the client. You
are sending a binary file.

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com

A watched clock never boils.

"JIM.H." <JI**@discussions.microsoft.comwrote in message
news:84**********************************@microsof t.com...
private void DownloadFile(string fName)
{
string msg="download done";

/*
System.IO.fInfo fInfo = new System.IO.fInfo(fName);
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" +
fInfo.Name);
Response.AddHeader("Content-Length", fInfo.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.WriteFile(fInfo.FullName);
*/

this.myLabel.ForeColor=System.Drawing.Color.Red;
this.myLabel.Text=msg;
}

When I remove commented section, this method does not show the message in
myLabel on my page, where is the problem?


Sep 24 '06 #3
Sure, don't include any code that generates HTML in your page.

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com

A watched clock never boils.

"JIM.H." <JI**@discussions.microsoft.comwrote in message
news:3E**********************************@microsof t.com...
Thanks Kevin, I am trying to make sure I am getting open/save dialog box,
any
solution for me?

"Kevin Spencer" wrote:
>The problem is that you're not sending an HTML document to the client.
You
are sending a binary file.

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com

A watched clock never boils.

"JIM.H." <JI**@discussions.microsoft.comwrote in message
news:84**********************************@microso ft.com...
private void DownloadFile(string fName)
{
string msg="download done";

/*
System.IO.fInfo fInfo = new System.IO.fInfo(fName);
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" +
fInfo.Name);
Response.AddHeader("Content-Length", fInfo.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.WriteFile(fInfo.FullName);
*/

this.myLabel.ForeColor=System.Drawing.Color.Red;
this.myLabel.Text=msg;
}

When I remove commented section, this method does not show the message
in
myLabel on my page, where is the problem?




Sep 24 '06 #4
Ok. How should I show open/save dialog box if an excel file is selected. It
will open in the browser, that is what we do not want.

"Kevin Spencer" wrote:
Sure, don't include any code that generates HTML in your page.

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com

A watched clock never boils.

"JIM.H." <JI**@discussions.microsoft.comwrote in message
news:3E**********************************@microsof t.com...
Thanks Kevin, I am trying to make sure I am getting open/save dialog box,
any
solution for me?

"Kevin Spencer" wrote:
The problem is that you're not sending an HTML document to the client.
You
are sending a binary file.

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com

A watched clock never boils.

"JIM.H." <JI**@discussions.microsoft.comwrote in message
news:84**********************************@microsof t.com...
private void DownloadFile(string fName)
{
string msg="download done";

/*
System.IO.fInfo fInfo = new System.IO.fInfo(fName);
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" +
fInfo.Name);
Response.AddHeader("Content-Length", fInfo.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.WriteFile(fInfo.FullName);
*/

this.myLabel.ForeColor=System.Drawing.Color.Red;
this.myLabel.Text=msg;
}

When I remove commented section, this method does not show the message
in
myLabel on my page, where is the problem?




Sep 24 '06 #5
Here are some references you can use:

http://msdn.microsoft.com/library/de...efiletopic.asp
http://support.microsoft.com/default...b;en-us;307603

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com

A watched clock never boils.

"JIM.H." <JI**@discussions.microsoft.comwrote in message
news:9C**********************************@microsof t.com...
Ok. How should I show open/save dialog box if an excel file is selected.
It
will open in the browser, that is what we do not want.

"Kevin Spencer" wrote:
>Sure, don't include any code that generates HTML in your page.

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com

A watched clock never boils.

"JIM.H." <JI**@discussions.microsoft.comwrote in message
news:3E**********************************@microso ft.com...
Thanks Kevin, I am trying to make sure I am getting open/save dialog
box,
any
solution for me?

"Kevin Spencer" wrote:

The problem is that you're not sending an HTML document to the client.
You
are sending a binary file.

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com

A watched clock never boils.

"JIM.H." <JI**@discussions.microsoft.comwrote in message
news:84**********************************@microso ft.com...
private void DownloadFile(string fName)
{
string msg="download done";

/*
System.IO.fInfo fInfo = new System.IO.fInfo(fName);
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" +
fInfo.Name);
Response.AddHeader("Content-Length", fInfo.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.WriteFile(fInfo.FullName);
*/

this.myLabel.ForeColor=System.Drawing.Color.Red;
this.myLabel.Text=msg;
}

When I remove commented section, this method does not show the
message
in
myLabel on my page, where is the problem?





Sep 24 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Jenski182 | last post by:
Is this from a good coder? or a rubbish one? Whichever way, it was paid for his services, just want to know if its worth while.... Thanks Jen x #include <iostream.h> #include <conio.h>
9
by: datastructure | last post by:
Copyright (c) 2003 by James J. Perry. All Rights Reserved. char Square::validList = {'r', 'g', 'b'}; //missing an element, is 0 int Square::numValues = 3; Square::Square() { value =...
5
by: cc0064263 | last post by:
hello, i am very new to C and i am reading K&R and i came accross this code in the book. K&R says that it is incorrect to free something after it has been freed and gives this as an example. ...
6
by: Niklaus | last post by:
Hi, Can someone point out what is wrong with this code ? How can i make it better optimize it. When run it gives me seg fault in linux. But windows it works fine(runs for a long time). Do we...
2
by: Rui Macdonald | last post by:
What is wrong with this code to populate a DropDownList? Can somebody Help me? Tnx RMac ===================================================================================== WebForm.aspx.vb
6
by: doncee | last post by:
This is the set up: is a date field on a form. Its control source is the field "date_entered" in"Table1". If there is a date showing in the date_entered field (Text6) & the status in Combo box2...
28
by: hijkl | last post by:
hey guys anything wrong with this code?? if it is then what? int *array(int n){ return new int(n); } int main(){ int *p = array(10); for( int i = 0; i < 10; i++ ) {
5
by: Jeff | last post by:
ASP.NET 2.0 This code crashes. It generate this error: Value cannot be null. Parameter name: type I've created some custom web.config settings and this crash is related to accessing theme...
3
by: Koliber (js) | last post by:
I feel i still do not understand maybe a bit a dispose pattern So I have a question - is this code right? Is fs.Close() there where it is right? If I do understand it in place 'BBB' there can be a...
2
by: ccgrl451 | last post by:
Okay, so you probably haven't seen my previous question, whats wrong with this code. For those who have, you know what I'm talking about. If not, heres what I have to do. We have to do this...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.