H
hullnwm
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 = @"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.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
System.Web.UI.Page.ProcessRequestMain()
Any advise you can give would be greatly appreciated.
Thanks,
IpPhD
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 = @"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.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
System.Web.UI.Page.ProcessRequestMain()
Any advise you can give would be greatly appreciated.
Thanks,
IpPhD