文件上传完成后无法更改标签文本

时间:2019-06-04 07:36:35

标签: javascript asp.net

我正在创建文档上传表单。我想在文件上传完成事件之后显示一个包含“文件上传完成”的标签。

这是我的aspx页面

<table style="width: 100%; border-spacing: 30px; text-align: left;" cellpadding="20">
  <tr>
    <td style="width:150px">Staff Requisition & Approval</td>
    <td style="width:220px">
      <dx:ASPxUploadControl AdvancedModeSettings- TemporaryFolder="~/HumanResources/EmpDocuments/" Theme="MetropolisBlue" ID="ASPxUploadControl1" ClientInstanceName="UploadControl" runat="server" UploadMode="Standard" AutoStartUpload="True" Width="200" ShowProgressPanel="True"
        CssClass="uploadControl" DialogTriggerID="externalDropZone" OnFileUploadComplete="UploadControl1_FileUploadComplete">
        <AdvancedModeSettings EnableDragAndDrop="True" EnableFileList="False" EnableMultiSelect="True" ExternalDropZoneID="externalDropZone" DropZoneText="" />
        <ValidationSettings AllowedFileExtensions=".pdf" NotAllowedFileExtensionErrorText="Only .pdf format is allowed">
        </ValidationSettings>
        <BrowseButton Text="Browse" />
        <DropZoneStyle CssClass="uploadControlDropZone" />
        <ProgressBarStyle CssClass="uploadControlProgressBar" />
      </dx:ASPxUploadControl>
      <asp:Label ID="lbl1" runat="server" Text=""></asp:Label>
    </td>
    <td>
      <dx:ASPxCheckBox ID="chk_Type1" runat="server" Text="Received">
      </dx:ASPxCheckBox>
    </td>
  </tr>

这是我后面的代码

protected void UploadControl1_FileUploadComplete(object sender, FileUploadCompleteEventArgs e)
{
    if (tbEmployeeNumber.Text != "")
    {
        Session["EmployeeNumber"] = tbEmployeeNumber.Text;
    }

    try
    {
        if (ASPxUploadControl1.HasFile)
        {
            string name = ASPxUploadControl1.UploadedFiles[0].FileName;

            Stream ss = ASPxUploadControl1.UploadedFiles[0].FileContent;

            var Empdoc = new ML_Document
            {
                Description = tbDocumentDescriptionNew.Text,
                Doc_path = new FTPHelper(ALMANAC.Web.HumanResources.PersonalizedHelpers.GlobalEnum.FTPCredentialsMode.Server716).UploadFileByFolder(true, Session["EmployeeNumber"] + "_" + name, "EmployeeDocuments/" + Session["EmployeeNumber"] + "/", ss, "FileName"),
                EmpNumber = Convert.ToInt32(Session["EmployeeNumber"]),
                Updated_by = Session["User"] != null ? ((AdUser)Session["User"]).EmpNumber : 0,
                Doc_Type_ID = 1
            };

            if (new BL_Document().AddDocument(Empdoc))
            {
                chk_Type1.Checked = true;
                chk_Type1.Enabled = false;
                lbl1.Text = "File Uploaded Complete";
            }
        }
    }
    catch (Exception ex)
    {
        throw ex;
    }
}

我希望输出“文件上传完成”,但是什么也没显示。 文件正确上传。

这是代码BL_Document()。AddDocument(Empdoc)

  public bool AddDocument(ALMANAC.Model.HRIS.ML_Document Document)
    {
        var par = new SqlParameter[]{
            new SqlParameter("@Description",Document.Description),
            new SqlParameter("@Doc_path",Document.Doc_path),
            new SqlParameter("@EmpNumber",Document.EmpNumber),
            new SqlParameter("@Updated_by",Document.Updated_by),
            new SqlParameter("@DocumentTitle",Document.Doc_Type_ID)
        };

        SqlHelper.ExecuteNonQuery(DBConnection.HRHDT, CommandType.StoredProcedure, "sp_HRS_Document_INUP", par);
        return true;
    }

1 个答案:

答案 0 :(得分:0)

尝试首先定义新的BL_Document。可能与this post中所述的在if语句中定义变量有关。

var BLDoc = new BL_Document();
if (BLDoc.AddDocument(Empdoc))
    {
    ...