2014-11-06 17 views
1

最初有單獨的aspx頁面和所有工作正常,然後我不得不實施它到主頁面。 此代碼是在幾年前完成的,現在需要轉換爲html5。從主頁面內的發件人對象findcontrold - asp.net

什麼工作是當我提到的控件名稱明確

'find contentplaceholder 

Dim mpContentPlaceHolder As ContentPlaceHolder 
     mpContentPlaceHolder = CType(Master.FindControl("HomePlaceholder"), ContentPlaceHolder) 
'find the control 
     AnnounceSnippet = DirectCast(mpContentPlaceHolder.FindControl("AnnounceSnippet"), Control.ContentSnippet) 

主模板的實施之前,以下是工作的罰款

#Region "View Particular Day" 
    Public Sub lbtDayView_Click(ByVal sender As Object, ByVal e As System.EventArgs) 

    Dim dtmSelectedDate As DateTime = DirectCast(Page.FindControl(DirectCast(sender, Calendar).ClientID), Calendar).SelectedDate() 

但後來因爲它給空指針異常我試圖使用主內容持有人

Dim dtmSelectedDate As DateTime = DirectCast(mpContentPlaceHolder.FindControl(DirectCast(sender, Calendar).ClientID), Calendar).SelectedDate() 

sti我不知道。

誰能好心幫>

這裏是我的aspx

<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="HomePlaceholder"> 
...... 
<uc1:contentsnippet id="AnnounceSnippet" runat="server"></uc1:contentsnippet> 
..... 
<asp:calendar id="Calendar1" runat="server"></asp:calendar> 

</asp:Content> 

回答

0

啊發現它!。

當我做了一個調試,它返回「HomePlaceholder_Calendar1」作爲clientID而不僅僅是「Calendar1」,所以做了一個字符串替換,我知道它不是正確的方式,但它是唯一的方式,我有現在去解決它。

相關問題