FindControl来自母版页内的发件人对象-asp.net
最初有单独的aspx页面,所有页面都运行良好,然后我必须将其实现到母版页中。 这段代码是几年前完成的,现在需要转换成html5 当我明确提到控件名称时,工作原理是什么FindControl来自母版页内的发件人对象-asp.net,asp.net,vb.net,master-pages,Asp.net,Vb.net,Master Pages,最初有单独的aspx页面,所有页面都运行良好,然后我必须将其实现到母版页中。 这段代码是几年前完成的,现在需要转换成html5 当我明确提到控件名称时,工作原理是什么 'find contentplaceholder Dim mpContentPlaceHolder As ContentPlaceHolder mpContentPlaceHolder = CType(Master.FindControl("HomePlaceholder"), ContentPlaceHold
'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()
还是没有线索
有人能帮忙吗>
这是我的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>
......
.....
啊,找到了
当我对它进行调试时,它将“HomePlaceholder_Calendar1”作为clientID返回,而不是仅仅返回“Calendar1”,因此字符串被替换,我知道这不是正确的方法,但这是我现在唯一能解决它的方法