Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 7th, 2008, 06:21 AM
Authorized User
 
Join Date: Jun 2006
Posts: 88
Thanks: 0
Thanked 0 Times in 0 Posts
Default ASp.net dialog box

Hi all
In my asp.net page I'm attempting to use the OpenfileDialog object to
offer a common dialog box for the user to select a particular file on their
hard drive that may subsequently be uploaded
to our website.
The reason I'm doing it this way is that I've read that by using the common
dialog box, the security issues are based on the logged in user.

Of course, I added a reference to System.Windows.Forms and added a using
clause.

Here's the problem, when I use the following code

OpenFileDialog ofd = new OpenFileDialog();
ofd.Title = "Choose File";
ofd.InitialDirectory = [at] "c:\" ;
ofd.Filter = "All files (*.*)|*.*|All files (*.*)|*.*" ;
ofd.FilterIndex = 1 ;
ofd.RestoreDirectory = true ;
ofd.ShowDialog();

ShowDialog() throws the following exception:

[InvalidOperationException: It is invalid to show a modal dialog or form
when the application is not running in
UserInteractive mode. Specify the ServiceNotification or DefaultDesktopOnly
style to display a notification
from a service application.]
System.Windows.Forms.CommonDialog.ShowDialog()
TestPortal1.AttachFileForm.btnBrowse_Click(Object sender, EventArgs e) in
c:\inetpub\wwwroot\testportal1\attachfileform.aspx .cs:73
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEven tHandler.RaisePostBackEvent(String
eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
System.Web.UI.Page.ProcessRequestMain()

Any advise you can give would be greatly appreciated.

Thanks,
monika

 
Old January 7th, 2008, 07:00 AM
Authorized User
 
Join Date: Jul 2007
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to mujahidkhaleel
Default

OpenFileDialog is a Windows Forms component. This will not work with ASP.NET. The ASP.NET applications runs as a service on server, and it is not an user interactive mode.

This URL should help you out http://support.microsoft.com/kb/323245

Mujahid Khaleel
Web designing, development, E-commerce applications.
 
Old January 7th, 2008, 10:32 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You need to use the HTML file input control.

http://msdn2.microsoft.com/en-us/lib...ileupload.aspx

-Peter





Similar Threads
Thread Thread Starter Forum Replies Last Post
call window dialog component with asp.net/vb.net s3ng ASP.NET 1.x and 2.0 Application Design 0 June 21st, 2005 04:54 AM
SAVE dialog in ASP.NET(VB.NET) sajid_pk ASP.NET 2.0 Basics 1 June 15th, 2005 10:40 AM
A Yes/No dialog equivalent under asp.net badgolfer ASP.NET 1.0 and 1.1 Basics 2 June 11th, 2004 09:27 PM
insert dialog box in a dialog box BurhanKhan Visual C++ 7 June 1st, 2004 07:53 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.