使用contentpage / masterpage时,我无法在点击按钮时在asp.net中运行进度条代码。
我已经检查了没有母版页的代码它工作很酷..但在使用时遇到问题
母版。
我无法弄清楚的问题是什么?
<%@ Page Title="" Language="C#" MasterPageFile="~/Admin.master" AutoEventWireup="true" CodeFile="UploadStudentDB.aspx.cs" Inherits="Admin_UploadStudentDB" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Contentplaceholder2" Runat="Server">
<script language="javascript" type="text/javascript">
var size = 2;
var id = 0;
function ProgressBar() {
if (document.getElementById('<%=txtFilePath.ClientID %>').value != "")
{
document.getElementById("divProgress").style.display = "block";
document.getElementById("divUpload").style.display = "block";
id = setInterval("progress()", 20);
return true;
}
else {
alert("Select a file to upload");
return false;
}
}
function progress() {
size = size + 1;
if (size > 299) {
clearTimeout(id);
}
document.getElementById("divProgress").style.width = size + "pt";
document.getElementById("<%=lblPercentage.ClientID %>").
firstChild.data = parseInt(size / 3) + "%";
}
</script>
<body>
<div id="divUpload" style="display:none">
<div style="width:300pt;text-align:center;">Uploading...</div>
<div style="width:300pt;height:20px; border:solid 1pt gray">
<div id="divProgress" runat="server"
style="width: 1pt; height: 20px; background-color:Gray;display:none">
</div>
</div>
<div style="width:300pt;text-align:center;">
<asp:Label ID="lblPercentage" runat="server"
Text="Label"></asp:Label></div>
</div>
<div align="center">
<table style="width: 100%; background-color:Silver" border="1">
<tbody align="center">
<tr>
<td align="center">
<asp:Label ID="Label2" runat="server" Font-Bold="True" Font-Size="XX-Large"
Text="Please Select Excel File Containg Student Details..." ForeColor="White"
Font-Underline="True"></asp:Label>
</td>
</tr>
<tr>
<td>
<div style="background: url(hline.gif) repeat-x bottom #F2F2F2;padding: 8px 5px;border-bottom: 1px solid #ccc;">
<asp:FileUpload ID="txtFilePath" runat="server"></asp:FileUpload>
<asp:Button
ID="btnUpload" runat="server" Text="Upload" OnClientClick="return ProgressBar();" onclick="btnUpload_Click" />
<br />
<asp:Label ID="lblMessage" runat="server" Visible="False" Font-Bold="True"
ForeColor="#009933" Font-Size="Large"></asp:Label>
</div>
</td>
</tr>
<table>
</div>
答案 0 :(得分:1)
我猜这是关闭body
标记之后的流氓script
标记。