This is a migrated thread and some comments may be shown as answers.

upload file dialog problem. Help please

3 Answers 107 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Yong
Top achievements
Rank 1
Yong asked on 12 Oct 2011, 06:54 PM

Hi, I am using upload file dialog to upload files. the upload file dialogs exist in multiple pages. when the dialgo opens, however, sometimes it uses the previous file path from UI. do I do anything wrong? I have debugged and the filePath is correct but from UI I can see the actual file path entered in the dialog is from previous page's upload file dialog. I am using IE8. Thanks!

 

FileUploadDialog

 

 

uploadDialog = new FileUploadDialog(manager.ActiveBrowser, filePath, dismissButton, dialogTitle);

 

manager.DialogMonitor.AddDialog(uploadDialog);

manager.DialogMonitor.Start();

browsebutton.Click();
 

uploadDialog.WaitUntilHandled(5000);

manager.DialogMonitor.Stop();

manager.DialogMonitor.RemoveDialog(uploadDialog);

3 Answers, 1 is accepted

Sort by
0
Anthony
Telerik team
answered on 12 Oct 2011, 10:50 PM
Hello Yong,

Please refer to the code below where I successfully upload two file with different paths to a public site:

Manager.LaunchNewBrowser(BrowserType.InternetExplorer);
ActiveBrowser.NavigateTo("http://encodable.com/uploaddemo/");
 
var x = new FileUploadDialog(ActiveBrowser, @"C:\test.txt", DialogButton.OPEN);
Manager.DialogMonitor.AddDialog(x);
Manager.DialogMonitor.Start();
 
Element e2 = Find.ById("uploadname1");
Actions.Click(e2);
 
ActiveBrowser.RefreshDomTree();
 
Element e3 = Find.ById("uploadbutton");
Actions.Click(e3);
 
x.WaitUntilHandled(10000);
System.Threading.Thread.Sleep(5000);
Manager.DialogMonitor.Stop();
             
ActiveBrowser.NavigateTo("http://encodable.com/uploaddemo/");
 
var y = new FileUploadDialog(ActiveBrowser, @"C:\HTML\test2.txt", DialogButton.OPEN);
Manager.DialogMonitor.AddDialog(y);
Manager.DialogMonitor.Start();
 
Actions.Click(e2);
ActiveBrowser.RefreshDomTree();
Actions.Click(e3);
 
y.WaitUntilHandled(10000);
System.Threading.Thread.Sleep(5000);
Manager.DialogMonitor.Stop();

Greetings,
Anthony
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Yong
Top achievements
Rank 1
answered on 12 Oct 2011, 11:41 PM
thanks Anthony for your reply.
so we dont' have to remove the dialog by using:
manager.DialogMonitor.RemoveDialog(uploadDialog);

Thanks again.

Yong
0
Anthony
Telerik team
answered on 13 Oct 2011, 04:22 PM
Hi Yong,

My example will work without that line, so it's not absolutely necessary. You can include it if you want to remove a single dialog from the list of dialogs to monitor.

Regards,
Anthony
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
General Discussions
Asked by
Yong
Top achievements
Rank 1
Answers by
Anthony
Telerik team
Yong
Top achievements
Rank 1
Share this question
or