Click here to Skip to main content
15,445,242 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi all,

I have created a simple web application. It has two buttons one for browsing folder (selectFolderbtn) & another for browsing file (selectFilebtn) . And the click event for both the buttons are as below:-
protected void selectFolderbtn_Click(object sender, EventArgs e)
     Thread thdSyncRead = new Thread(new ThreadStart(openfolder));

 public void openfolder()

     FolderBrowserDialog fbd = new FolderBrowserDialog();
     DialogResult result = fbd.ShowDialog();

     string selectedfolder = fbd.SelectedPath;
     txt_extDestLoc.Text = selectedfolder;


protected void selectFilebtn_Click(object sender, EventArgs e)
     Thread thdSyncReadNew = new Thread(new ThreadStart(selectfile));


public void selectfile()

     OpenFileDialog fileD = new OpenFileDialog(); //create object
     fileD.Filter = "Iso files|*.iso;"; //define filter
     fileD.ShowDialog(); //show dialog
     string globalisopath = fileD.FileName;

The issue I am facing is among the above two button click event only one event works at a time & not both the event. I want both the click event to work, one should select a folder & another should select a file. But its not working the way I want.

Why this is happening. Please suggest me its solution or any other alternatives.

Thanks for help.
Updated 13-Jan-15 21:06pm
Kornfeld Eliyahu Peter 14-Jan-15 3:13am    
Are you sure this is a WEB application?
Vishwaeet 14-Jan-15 6:01am    
Yes this is a web application
Vishwaeet 14-Jan-15 6:00am    
Yes I am using above code in a web application.
Philippe Mori 14-Jan-15 12:32pm    
The above code don't make sense. Files and folder dialogs are not intended for web applications. And for desktop applications, you should never access directly the UI from multilple threads so it absolutly make no sense at all to start a thread to display dialogs. Also these dialogs are intended to be used modally so it would be confusing to do otherwise. And by the way, I would not recommand the use of folder dialog as it is somewhat obsolete and it don't allows the user to see files in selected folder...

1 solution

You are lack basic knowledge of what web application is!
Reading your code one can get the idea that you are trying to open file/folder dialog boxes of Windows...

You have to understand that web applications are disconnected applications...There is a part that run inside the browser on the client machine (contains HTML/CSS/JavaScript) and there is a part that run inside the web server (IIS/Apache) on the server machine. Your code belongs to the server side of the application and every peace of code runs on the server and for that it's all wrong (it try to open dialog boxes on the server!)...

As I told - you have to start again with the very basics of web development...
Share this answer
Vishwaeet 14-Jan-15 7:33am     CRLF
Thanks for your guidance. I understood the difference between windows application & web application. I must start learning web development afresh. Thanks.
Kornfeld Eliyahu Peter 14-Jan-15 7:35am    
Good luck...visit us with your questions :-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900