执行onclientclick后onclick中的代码不执行
为什么我执行了onclientclick中的代码后onclick中的代码会不执行呢?
代码如下:
<head>
<link href="css/Styles.css" type="text/css" rel="stylesheet" />
<link href="css/Login.css" rel="stylesheet" type="text/css" />
<base target="_self" />
<script type="text/javascript">
function ChnageShow()
{
var bUp=document.getElementById("BtUpload");
var bShow=document.getElementById("showUP");
bUp.disabled=true;
bShow.style.display="";
return true;
}
</script>
</head>
<body class="bg_color">
<form id="form1" runat="server">
<input type="hidden" id="tableName" name="tableName" style="width:1px;" runat="server"/>
<input type="hidden" id="recid" name="recid" style="width:1px;" runat="server" />
<div style="margin-left:20px;margin-top:20px; margin-bottom:5px; width:460px;">
<table style="width:460px;">
<tr>
<td style="width:460px;">
<asp:FileUpload ID="file1" style="width:455px;" runat="server" /><br />
<asp:TextBox ID="des1" TextMode="MultiLine" Rows="3" Width="450px" runat="server" ToolTip="输入上传原文的描述信息"></asp:TextBox><br />
</td>
</tr>
</table>
</div>
<div style="margin-left:20px; margin-top:1px;width:460px;">
<asp:CheckBox ID="chkTrans" runat="server" Text="电子文件转换" />
<asp:CheckBox ID="chkFullText" runat="server" Text="全文内容提取 (只适用 OFFICE、PDF、TXT 等类型文件)" />
</div>
<div id="showUP" runat="server" style="margin-left:20px; margin-top:10px;width:460px; text-align:center; display:none;">
<asp:Label ID="sTile" runat="server" Text="正在上传电子文件..."></asp:Label>
<img id="img1" src="images/Loading/loading2.gif" />
</div>
<div style="width:460px; margin-left:17px;margin-top:20px;">
<asp:Button ID="BtUpload" runat="server" Text="开始上传" Width="80px" onclientclick="ChnageShow()" onclick="BtUpload_Click" />
<asp:Button ID="btn_close" runat="server" OnClientClick="javascript:self.close()" Text="退出" Width="80px" />
</div>
</form>
</body>
以下为后台代码:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
Me.tableName.Value = Request("table") & ""
Me.recid.Value = Request("recid") & ""
Me.BtUpload.Attributes.Add("onclick","ChnageShow()")
End If
End Sub
Protected Sub BtUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtUpload.Click
Dim fileinfo As HttpPostedFile
Dim file_id As String
Dim file_name As String
Dim file_Extension As String
Dim file_loc As String
'数据库字段
Dim time_subpath As String
Dim root, web_path As String
Dim user_id As String = getUserId()
Dim user_name As String = getUserName()
Dim Descript As String = Me.des1.Text.Replace("'", "‘")
Dim DFiles As String()
Dim sFileID As String
Try
fileinfo = Me.file1.PostedFile
If fileinfo.ContentLength <= 0 Then
Alert("文件为空,请选择其它文件。")
Me.BtUpload.Enabled = True
Me.showUP.Visible = False
Exit Sub
End If
'读取服务端设置
'读取文件属性
file_id = Getrecid()
file_name = Path.GetFileName(fileinfo.FileName)
file_Extension = Path.GetExtension(fileinfo.FileName)
time_subpath = getTimeSubPath()
'filename = file_id & file_Extension
file_loc = "\" & Me.tableName.Value & "\" & time_subpath & "\" & Me.recid.Value.Trim("'") & "\"
root = Server.MapPath(Request.ApplicationPath) & "\" & SourceFile & file_loc
web_path = root & file_name 'filename
MakeDirectory(Server.MapPath(Request.ApplicationPath) & "\" & SourceFile, True)
MakeDirectory(root)
fileinfo.SaveAs(web_path)
ReDim Preserve DFiles(0)
DFiles(0) = web_path
With ODoc
.DatabaseType = mDatabaseInfo.DataType
.Connection = mDatabaseInfo.ConnectString
.AddDocByName(Me.tableName.Value, "recid", Me.recid.Value, DFiles)
sFileID = .FileDocID
If .ErrorMessage <> "" Then
Alert(ODoc.ErrorMessage)
Else
If Me.chkTrans.Checked = True Then
TrnaToSWF(DFiles(0), sFileID)
End If
Alert("文件上传成功")
End If
End With
BtUpload.Enabled = True
Me.showUP.Visible = False
Catch ex As Exception
BtUpload.Enabled = True
Me.showUP.Visible = False
Alert(ex.Message.ToString)
End Try
End Sub