|
Hello:
I have a web page that is sending a MS-Word file to be showed.
Code I’m using is:
Response.ClearContent();
Response.ClearHeaders();
Response.Clear();
Response.ContentType = "application/msword";
Response.Charset = "";
Response.AddHeader("Content-disposition", "inline; filename=ExportPath");
Response.AddHeader("Content-Length", sFileLength);
Response.WriteFile(ExportPath);
Response.Flush();
Response.Close();
System.IO.File.Delete(ExportPath);
If file to display was not MS-Word neither MS-Excel, as a PDF file, then dialog box is not showed.
How can I in MS files to such dialog not be showed?
A.L.
El hombre que tiene amigos debe mostrarse amigo...
|
|
|
|
|
1) Your question actually belongs in the ASP.NET[^] forum. I'll answer anyway.
2) I'm afraid I don't understand you. Are you saying that when you download a Word document to the client browser you want it displayed directly like a PDF does if you have a viewer installed? You have no control over that. You can trick the client into showing a "Save as" dialog box by sending "application/octet-stream" for any file type, since that's perceived as a binary file. Whether or not Word - or any other application - displays directly in the Active Document container (i.e., Internet Explorer) is up to the client configuration.
For example, if a PDF viewer like Acrobat was not installed, you would be prompted to save. Depending on Word settings, a Word document will either open the browser or prompt to save. Even Acrobat has a setting that controls whether it's hosted in the Active Document container or opened in a separate windows application.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Thanks you for your reply.
Excuse me if I was not clear enough.
I want when I display a word document (into IE) document being dispalyed directly without a dialog box asking user if he desieres to open / save this document. Similarly as happens with PDF documents.
You wrote that using "application/octet-stream" is possible do "trick" client being able to display document directly.
I tried it and don't work.
I hope you'll have some idea about it.
El hombre que tiene amigos debe mostrarse amigo...
|
|
|
|
|
No, I said application/octet-stream would trick the browser into prompting to save, even for a text document. Applications like Word and Acrobat have settings that determine whether or not they will activate within the Active Document container (Internet Explorer) or in their own application window.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Does it means that I must desist to achieve my goal to avoid open/save dialog box with Words & Excel documents?
El hombre que tiene amigos debe mostrarse amigo...
|
|
|
|
|
No, it means that you need to put up a help topic on your web site that helps users configure their applications properly. Your server can't configure the client for them, as that would be a serious security vulnerability.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
PS: If you're the guy that asked something similar before, then I'm sorry but I didn't understand your first question because of the extra code you included regarding the Crystal Reports document.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi
Is it possible to create a new instance of an object at runtime??
-If possible how?? (a form is a good starting point)
Thx,
Besinci
|
|
|
|
|
|
Thx a lot,
This is what I was looking for
|
|
|
|
|
hi guys, could anyone please help me in my program, the thing is that i want to write a function that calculates the check digit in EAN-13 barcode symbology.
thnx
|
|
|
|
|
In VB6 I was able to use MCM_SETFIRSTDAYOFWEEK to set Monday as the first day of the week in the DateTimePicker calendar (in the dtp.DropDown event). My attempts to port the same API call to the C# version have been unsuccessful; it compiles and runs, but it doesn't change the first day of the week in the calendar. I've included both the VB6 and C# code below. (Note: the declarations and DropDown code are in the same form).
'VB6
'**************************************************************************
'Needed for DateTimePicker calendar "first day of week"
Const DTM_FIRST = &H1000
Const DTM_GETMONTHCAL = DTM_FIRST + 8
Const MCM_FIRST = &H1000
Const MCM_SETFIRSTDAYOFWEEK = MCM_FIRST + 15
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hWnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, ByVal lParam As Any) As Long
'**************************************************************************
In the VB6 DTPicker DropDown event
'Get a reference to the handle of the DateTimePicker control
lCalHwnd = SendMessage(ctlDateTimePicker.hWnd, DTM_GETMONTHCAL, 0&, ByVal 0&)
'Send an API message to change the presentation
' lCalHwnd = handle to the control
' MCM_SETFIRSTDAYOFWEEK = Flag for message to send
' 0& = Unused parameter
' 0& = Day of week (0 = Monday … 6 = Sunday)
SendMessage lCalHwnd, MCM_SETFIRSTDAYOFWEEK, 0&, ByVal 0&
// C#
private const int DTM_FIRST = 0x1000;
private const int DTM_GETMONTHCAL = DTM_FIRST + 8;
private const int MCM_FIRST = 0x1000;
private const int MCM_SETFIRSTDAYOFWEEK = MCM_FIRST + 15;
[DllImport("user32.dll",EntryPoint="SendMessageA")]
extern static IntPtr SendMessageFirstDayOfWeek(IntPtr hWnd, int wMsg, int wParam, int lParam);
In the C# DateTimePicker DropDown event
SendMessageFirstDayOfWeek(dtpStartDate.Handle, MCM_SETFIRSTDAYOFWEEK, 0, 0);
Any help would be greatly appeciated!
|
|
|
|
|
In you're code you're not using the MonthCalendar control's Handle like you are in your VB6 code. You must get the handle to the calendar first:
using System;
using System.ComponentModel;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;
class DTPSample : Form
{
DateTimePickerEx dtp;
[STAThread]
static void Main()
{
Application.Run(new DTPSample());
}
DTPSample()
{
dtp = new DateTimePickerEx();
Controls.Add(dtp);
dtp.FirstDayOfWeek = DayOfWeek.Monday;
dtp.Location = new Point(8, 8);
Text = "DTP Sample";
}
}
public class DateTimePickerEx : DateTimePicker
{
const int DTM_GETMONTHCAL = 0x1008;
const int MCM_SETFIRSTDAYOFWEEK = 0x100f;
DayOfWeek firstDayOfWeek;
[DllImport("user32.dll", CharSet=CharSet.Auto)]
static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam,
IntPtr lParam);
public DateTimePickerEx()
{
}
public IntPtr MonthCalendar
{
get
{
if (IsHandleCreated)
{
return SendMessage(Handle, DTM_GETMONTHCAL,
IntPtr.Zero, IntPtr.Zero);
}
return IntPtr.Zero;
}
}
[DefaultValue(DayOfWeek.Sunday)]
public DayOfWeek FirstDayOfWeek
{
get { return firstDayOfWeek; }
set
{
bool fireEvent = firstDayOfWeek != value;
firstDayOfWeek = value;
if (fireEvent)
OnFirstDayOfWeekChanged(EventArgs.Empty);
}
}
public event EventHandler FirstDayOfWeekChanged;
protected virtual void OnFirstDayOfWeekChanged(EventArgs e)
{
if (FirstDayOfWeekChanged != null)
FirstDayOfWeekChanged(this, e);
}
protected override void OnDropDown(EventArgs e)
{
base.OnDropDown(e);
if (MonthCalendar != IntPtr.Zero)
{
SendMessage(MonthCalendar, MCM_SETFIRSTDAYOFWEEK, IntPtr.Zero,
new IntPtr(firstDayOfWeek == DayOfWeek.Sunday ? 6 :
(int)firstDayOfWeek - 1));
}
}
} Also notice how I declare SendMessage using CharSet=CharSet.Auto in the DllImportAttribute . This will append "A" and "W" for the appropriate functions when necessary. This helps to produce robust assemblies. Declaring the parameters as the correct type - in this case, both wParam and lParam are actually IntPtr s - also helps. An IntPtr is the width of a pointer on the underlying platform.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Your example worked great! I see now that I was trying to use the handle to the DateTimePicker instead of the MonthCalendar component. I still don't completely understand the code, but it will give me something to study. Thank you for the help!
|
|
|
|
|
hi all.
i have created two forms. one form(Main form) has a text box. i am creating an object of the second form(Input form) and displaying it. now i take input from the user in this input form. then i close this form.
Now i want the input data to be displayed in the first form(main form). how can i do this??
thanking in anticipation
mahesh
|
|
|
|
|
Expose a property in the second form that gets the text input provided by the user and returns it. You can then access that property from the main form.
Regards
Senthil
My Blog
|
|
|
|
|
what is meant by exposing property exactly?
is it same as get set?
dfgdfgdfgdfg
|
|
|
|
|
You could use get set, or you could just write a small function that returns the value. Exposing it is just a fancy way of saying 'make it public'.
|
|
|
|
|
I am making a propertygrid that function like a "treeview" or "menubar". I want my propertygrid attribute to expand like a tree when the field of the attribute!="", and i want it to expand a sibling and a child like menu bar. I want all the expanded attribute to be editable too.
Is it posible to do that? How can i do that?
I have done half way... expand the attribute by returning a class to the propertygrid and the class contain attribute that is a expandableObject
When i expand the attribute the field of the attribute became uneditable. How can i make it editable?
Please help...
|
|
|
|
|
Hi,
I want to access the methods in a C# dll. How can I use it in Visual C++ 6.0?
It's a simple dll. I don't want COM stuff get invoke. Because I am not familar with COM and I don't want to be bothered with registry stuff. Any idea?
Thanks in Advance.
|
|
|
|
|
|
If you we're going the other way (using a VC++ .DLL in C#), it would be simple. But using a C#, or any other managed language, you have to go through COM to bridge between the two execution enviornments.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
What would be the fastest way to count the number of set bits in a byte?
I currently use a static array which has the number of bits set for each possible combination of set bits then use the byte value to index into that array.
Are there faster ways to do it?
|
|
|
|
|
|
Is it? Drat! It's where my code spends most of its time - although it is doing it billions of times so I don't suppose I can complain.
Thanks for the reply.
|
|
|
|