2009-05-22 90 views
0

我有以下用戶控制:ASP.NET/Jquery:文檔在更新面板中準備好了嗎?

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="FadingMessage.ascx.cs" Inherits="includes_FadingMessage" %> 

<asp:PlaceHolder Visible="false" runat="server" ID="plhMain"> 
<span id="<%= this.ClientID+"_panel" %>" style="background-color:yellow; padding:10px;"> 
<b><%= Message %></b> 
</span> 

<script type="text/javascript" language="javascript"> 

$(document).ready(function() { 
    alert("never gets here??"); 
    jQuery('#<%= this.ClientID+"_panel" %>').fadeOut(1000); 
}); 

</script> 

</asp:PlaceHolder> 

這是在一個asp使用:UpdatePanel中。我的問題是$(document).ready從未被解僱?

如何檢測部分渲染何時完成?

回答

1

把一個方法放在你的head標籤中,然後在你的佔位符中調用它。這裏的問題是你的PlaceHolder Visible =「false」,所以它永遠不會呈現。如果您通過ajax動態顯示它,腳本將不會運行。動態顯示佔位符時,必須重新綁定它。我會建議不要使用文件(準備好)...