2012-09-29 21 views
0

我使用下面的代碼來賦值到ASP.NET UpdateProgress控件,但有沒有運氣CSS值分配的UpdateProgress在JavaScript

<script type="text/javascript"> 
    var updateProgress=document.getElementById ('<%=UpdateProgressLinkActivity.ClientID%>'); 
    updateProgress.style.position='absolute'; 
    updateProgress.style.width='250px'; 
    updateProgress.style.height='100px'; 
    updateProgress.style.top='0px'; 
    updateProgress.style.left='0px'; 
    </script> 

控件名稱是一個複製粘貼。

+0

在函數中指定上面的代碼,您可以在每次更新時調用該函數。 –

+0

實際上元素髮生爲空。用調試器檢查。不知道爲什麼? – user1575229

+0

您檢查updateProgress值。它必須等於任何id。如果id不存在,則它將顯示null。更好地通過updateProgress –

回答

0

您在函數中添加此代碼,並在事件中添加以下代碼(forexample的onload)

<script type="text/javascript"> 
function VisibledProgress() 
{ 
    var updateProgress=document.getElementById ('<%=UpdateProgressLinkActivity.ClientID%>'); 
    updateProgress.style.position='absolute'; 
    updateProgress.style.width='250px'; 
    updateProgress.style.height='100px'; 
    updateProgress.style.top='0px'; 
    updateProgress.style.left='0px'; 
} 
</script> 

您的代碼.aspx的:

<asp:Button OnClientClick="VisibledProgress()" ..../> 
0

請試試這個:

var updateProgress=document.getElementById ('<%=UpdateProgressLinkActivity.ID%>'); 

使用此項:

<asp:UpdateProgress value="your getting cliend id" ID="UpdateProgressLinkActivity" runat="server" AssociatedUpdatePanelID="UpdatePanelLinkActivity" DynamicLayout="True"> <ProgressTemplate> <div style=" position:absolute; top:50%; left:50%; background-color:white;" id="divLoading"> <img src="Images/loading25.gif" alt="Loading..." style="" /> </div> </ProgressTemplate> </asp:UpdateProgress> 

指定值=「您獲取客戶端ID」。

並使用jquery - var updateProgress = $(「#UpdateProgressLinkActivity」)。val();

+0

您好,ClientID的拾取值,但這是錯誤的。當我用調試器檢查clientid是ctl00_ContentPlaceHolder1_GridViewStories_ctl17_UpdateProgressLinkActivity但當我在瀏覽器中檢查id時,那麼這是ctl00_ContentPlaceHolder1_GridViewStories_ctl02_UpdateProgressLinkActivity – user1575229

+0

好。你試試這個,把你的腳本放在頁面的最後。 –

+0

仍然沒有運氣.. – user1575229