如果被禁用,如何使用提交按钮回发到页面? [英] how do I postback to a page using a submit button if it was disabled?

查看:59
本文介绍了如果被禁用,如何使用提交按钮回发到页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有按钮,postbackurl设置为〜/ Search.aspx。它一直在工作,直到我将按钮的启用属性设置为false。当客户端使用此代码完成文件上传时,该按钮重新启用



document.getElementById(<%= btnUpload.C​​lientID%>)。禁用= false;



以下是我的按钮上传点击代码。它会在事件中执行所有操作,但不会回发到search.aspx。我知道这与禁用按钮有关。任何想法?





i have button that postbackurl is set to "~/Search.aspx". It was working up until i set the button's enable property to false. the button is reenabled wheni file upload is complete on client side using this code

document.getElementById("<%=btnUpload.ClientID%>").disabled = false;

the following is my code for my button upload click. it does everything in the event but it does not postback to search.aspx. I know it has to do with the disabling of the button. any ideas?


Private Sub btnUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpload.Click

        Dim strDept As String = cboDepartment.SelectedValue
        Dim strExt As String = System.IO.Path.GetExtension(uploadReport.FileName.ToString)
        Dim strFileName As String = String.Empty
        Dim strFilePath As String = String.Empty
        Dim strType As String = cboReportType.SelectedValue
        Dim strDate As String = txtReportDate.Text


        strDept = cleanUpDepartmentName(strDept)

        If uploadReport.HasFile Then
            strFileName = uploadReport.FileName.ToString
            strExt = System.IO.Path.GetExtension(uploadReport.FileName.ToString)
        Else
            lblMessage.Text = "No File"
        End If

        uploadReport.FailedValidation = fileValidation(strExt)

        'check if page is valid
        If Not (Page.IsValid) Or Not (uploadReport.FailedValidation = True) Then
            lblStatus.Text = "Please upload a valid file!"

            Return

        End If


        'creates the appropriate file path and file name
        If strType = "Monthly" Then
            strFileName = strType + "_" + strDept + "_" + strDate + strExt
            strFilePath = strgeminiPath + strType + "\" + strDept + "\"
            'create department folder
            Try
                If Not Directory.Exists(strFilePath) Then
                    Directory.CreateDirectory(strFilePath)
                End If

            Catch ex As DirectoryNotFoundException

            End Try



        ElseIf strType = "Annual" Then

            strFilePath = strgeminiPath + strType + "\" + strDept + "\"
            strFileName = strType + "_" + strDept + "_" + strDate + strExt
            'create department folder
            Try
                If Not Directory.Exists(strFilePath) Then
                    Directory.CreateDirectory(strFilePath)
                End If
            Catch ex As DirectoryNotFoundException

            End Try


        ElseIf strType = "Quarterly" Then

            strFilePath = strgeminiPath + strType + "\" + strDept + "\"
            strFileName = strType + "_" + strDept + "_" + strDate + strExt
            'create department folder
            Try

                If Not Directory.Exists(strFilePath) Then
                    Directory.CreateDirectory(strFilePath)
                End If

            Catch ex As DirectoryNotFoundException

            End Try

        End If


        strFileName = checkIfFileNameExists(strFilePath, strFileName, strExt)
        uploadReport.SaveAs(String.Format("{0}{1}", strFilePath, strFileName))
        Dim myDate As DateTime = CDate(strDate)
        'check to see if file was saved
        Dim strFullFilePath As String = Server.UrlPathEncode((String.Format("{0}{1}", strFilePath, strFileName)))

        'call stored procedure to insert data
        InsertReportData(strFullFilePath, strFileName, myDate)

        'call sub to send email
        Dim strdeptvalue As String = cboDepartment.SelectedValue

        generateEmail(strFullFilePath, strType, strDate, strdeptvalue)

    End Sub

推荐答案

这篇关于如果被禁用,如何使用提交按钮回发到页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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