【问题标题】:PostBack ist not executed after FileUpload.click() on some machines在某些机器上 FileUpload.click() 后没有执行 PostBack
【发布时间】:2014-07-08 13:39:26
【问题描述】:

我创建了一个 WebControl。上传文件的按钮在哪里。

我创建 Button 和 FileUpload 之类的

private readonly Button button;
public DocumentUploadButton() {
    button = new Button();
    button.Click += this.ProcessClick;
    var panel = new Panel();
    panel.Controls.Add(button);
    var fileUpload = new FileUpload();
    fileUpload.ID = "fileUploadHidden";
    fileUpload.Attributes["style"] = "display:none";

    panel.Controls.Add(fileUpload);
    Controls.Add(panel);
}

private void ProcessClick(object sender, EventArgs e) {
    if (this.fileUpload.PostedFile != null &&  string.IsNullOrEmpty(this.fileUpload.PostedFile.FileName)) {
       // Upload file and handle it like ...
       this.fileUpload.SaveAs(....)
    }
}

在 OnLoad 中我附加了一个 JavaScript 函数:

protected override void OnLoad(EventArgs e) {
   this.button.Attributes.Add("onclick", "document.getElementById('fileUploadHidden').click();");
   base.OnLoad(e);
}

现在,当用户单击按钮时,将调用 FileUpload 并显示 FileChooseDialog。这很好用。但在此之后,Click-Handler ProcessFile() 未在某些客户机器上执行(我认为 PostBack 未执行)。在我的开发者机器上,这工作正常。

谁能帮帮我,客户机器出了什么问题?

我们使用 InternetExplorer。

【问题讨论】:

    标签: c# javascript asp.net file-upload


    【解决方案1】:

    至少在我过去的情况下,可能是 IE 安全设​​置。要求他们将该站点添加到其计算机上的受信任站点

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-02-21
      • 1970-01-01
      • 2015-08-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-14
      • 2018-02-16
      相关资源
      最近更新 更多