Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8580547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:51:18+00:00 2026-06-11T20:51:18+00:00

I want to open a FolderBrowseDialog on button click in MVC razor(VB) syntax. For

  • 0

I want to open a FolderBrowseDialog on button click in MVC razor(VB) syntax.

For that i am calling a jquery function on “onclick” button event and through that function i am making a Post request to function in my controller that contains code to show FolderBrowseDialog.

here is my code.

Html:

<input type="button" class="btn" value="browse" onclick="SelectFolder()"/>

jquery:

<script type="text/javascript">


function SelectFolder()
{
    $.post("@Url.Action("FolderPicker", "Home")", function () {
            alert('sdd');
        },function(ex){
            alert("Error occured in AJAX");  
    });
}


</script>

Controller.. vb code to show FolderBrowserDialog.

<STAThreadAttribute()>
Sub FolderPicker()
    Dim browser As FolderBrowserDialog = New FolderBrowserDialog()
    browser.Description = "Select Folder"
    browser.ShowNewFolderButton = False
    browser.RootFolder = Environment.SpecialFolder.Desktop
    Dim result As DialogResult = browser.ShowDialog()

    If result = DialogResult.OK Then
        Dim selectedPath As String = browser.SelectedPath
    End If


End Sub

At
Dim result As DialogResult = browser.ShowDialog()
i am getting exception

Current thread must be set to single thread apartment (STA) mode before OLE  

calls can be made. Ensure that your Main function has STAThreadAttribute  

marked on it. This exception is only raised if a debugger is attached to the  

process.  

I also included STATreadAttribute() and STATread() but still i get this error.

Am i missing some thing?
Is there any other way to do it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T20:51:20+00:00Added an answer on June 11, 2026 at 8:51 pm

    FolderBrowseDialog is not available in ASP.NET/MVC.
    You can read some more stuff here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to open a website on a button click of asp.net web page.
i want to open a new pop up window when user click the button.But
I want to open a page in new tab of browser on button click.
i want to open a pop in my mvc3 razor application for that i
I want open Outlook if I click on a Button in a ListView. how
I want to open help.chm file when click on the help button. At present
I want to open two different links images in one window on one click.
I want to open info page through this link on uiwebview http://www.facebook.com/TinRoofNashville?sk=info But on
I want to open a pop-up window on click of 'link', then show some
I want to open a new window after clicking a button and I'm trying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.