2013-02-24 44 views
1

我無法在使用contentpage/masterpage的同時按鈕點擊時在asp.net中運行進度條代碼。
我檢查了沒有masterpage的代碼,它的工作很酷..但在使用 masterpage時出現問題。 什麼問題我無法弄清楚?
無法在使用母版頁時在內容頁中運行JavaScript

<%@ 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>&nbsp;&nbsp; 
            <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

附註...你不應該穿插這樣的兩種語言。將所有的asp變量寫入單個Json對象並從中讀取。 – 2013-02-24 15:52:14

+0

這可能是相關的http://stackoverflow.com/q/2155048/1741542 – 2013-02-24 15:52:28

+0

歡迎來到stackoverflow。如果你找到有用的答案,你可以放棄它。如果答案解決了您的問題,請接受它。另請參見[我如何在這裏提問?](http://stackoverflow.com/faq#howtoask) – 2013-02-24 15:57:50

回答

1

我想這是流氓body標籤剛剛閉幕script標記之後。

+0

graphicdivine:對不起,這是我的編輯問題.. – user2053138 2013-02-24 15:50:43

相關問題