单击“浏览”按钮打开Web应用程序后面的窗口 [英] opening the window at the back of the web application when clicked on browse button

查看:83
本文介绍了单击“浏览”按钮打开Web应用程序后面的窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  protected   void  btnbrowseInventory(对象发​​件人,EventArgs e)
{
线程thdSyncRead = 线程( new ThreadStart(openfolder));
thdSyncRead.SetApartmentState(ApartmentState.STA);
thdSyncRead.Start();
thdSyncRead.Join();

txtfilepath.Text = selectedfolder;
lblMessage.Visible = false ;
}

public void openfolder()
{
FolderBrowserDialog fbd = new FolderBrowserDialog();
DialogResult result = fbd.ShowDialog();

selectedfolder = fbd.SelectedPath;
}

解决方案

问题是,如果您在Web服务器上部署应用程序并尝试在客户端访问它,它将无法工作,您的页面将等待输入。



目前,您的客户端和服务器都在同一台机器上,因此您可以看到对话框(但该对话框在服务器端正常打开)。



您需要有一个自定义控件,它将在客户端打开。请查看以下链接: ASP.Net 2.0中的目录浏览 [ ^

protected void btnbrowseInventory(object sender, EventArgs e)
{
    Thread thdSyncRead = new Thread(new ThreadStart(openfolder));
    thdSyncRead.SetApartmentState(ApartmentState.STA);
    thdSyncRead.Start();
    thdSyncRead.Join();
    
    txtfilepath.Text = selectedfolder;
    lblMessage.Visible = false;
}

public void openfolder()
{
    FolderBrowserDialog fbd = new FolderBrowserDialog();
    DialogResult result = fbd.ShowDialog();
   
    selectedfolder = fbd.SelectedPath;
}

解决方案

The thing is, if you deploy the application on a web server and try to access it on client, It will not work and your page will hang waiting for an input.

Currently, your client and server both are on the same machine and hence you can see the dialog box(but that dialog is actully opening on server side).

You need to have a custom control which will open on client side. Check the link below: Directory Browsing in ASP.Net 2.0[^]


这篇关于单击“浏览”按钮打开Web应用程序后面的窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆