Click here to Skip to main content
15,892,480 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi

I have created a folderbrowsedialog for web in asp.net. It is working perfectly but the problem is folderbrowserdialog is opening behind the active window. I have to open the folderbrowserdialog infront of the active window.Can u pls help me with this (can u provide sample code)
Posted
Comments
v.chjen 16-Oct-12 12:55pm    
If you post sample of your code, it will be much easier and faster to solve your problem :)
Sergey Alexandrovich Kryukov 16-Oct-12 15:05pm    
Agree, because usually it works correctly. Must be something weird in the code using it.
--SA
revanth.crazy 18-Oct-12 3:16am    
Calling the Thread.....
=========================

<stathread()> _
Shared Sub Main()

End Sub


Code behind for button click event;.......
==========================================

Protected Sub button_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button.Click
dr = New DialogResult()
folderBrowserDialog1 = New System.Windows.Forms.FolderBrowserDialog()
InpfolderPath = STAShowDialog(folderBrowserDialog1)
If Not (InpfolderPath = "") Then
txtInpFilePath.Text = InpfolderPath
End If
End Sub


Calling the method STAShowDialog...
===================================

Private Function STAShowDialog(ByVal FD As FolderBrowserDialog) As String
Dim obj As cls_FolderDialog = New cls_FolderDialog
obj.fd = FD
Dim t As System.Threading.Thread = New System.Threading.Thread(AddressOf obj.FolderDialog)
t.SetApartmentState(System.Threading.ApartmentState.STA)
t.Start()
t.Join()
Return obj.strfilename
End Function


Class cls_FolderDialog...
=========================

Public Function FolderDialog() As String
DialogResult1 = New DialogResult
fd = New FolderBrowserDialog
fd.ShowNewFolderButton = "False"
fd.Description = "Select Input Folder"
DialogResult1 = fd.ShowDialog()
strfilename = fd.SelectedPath
Return strfilename
End Function

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