母版页控件需要访问另一个webform而不是子页面 [英] master page control needs to acces in another webform not a child page
问题描述
你好,
i有网页应用程序作为母版页和子页面。
i有一个母版页上的标签。我可以在任何子页面中访问此标签控件,如下所示
child.aspx
< ;%@ MasterType VirtualPath =〜/ MasterPage / Site1.Master%>
child.aspx.cs
((标签)this.Master.FindControl(lblsample))。文字=欢迎;
但是,我应该有这样的情况显示母版页面内容。所以我创建了一个名为'newlogin.aspx'的新webform,没有包含head,body标签的母版页。
现在如果我尝试访问newlogin.aspx中的母版页控制标签.cs,我收到NULL引用异常。
newlogin.aspx
<%@ MasterType VirtualPath =〜/ MasterPage / Site1.Master%>
newlogin.aspx.cs
((标签)this.Master.FindControl(lblsample))。Text =Welcome;
我收到NULL引用异常,因为它没有找到。
如何在这种情况下访问母版页控件。
Hello,
i have web application which as master page and child page.
i have one label on master page. i am able to access this label control in any child page like follow
child.aspx
<%@ MasterType VirtualPath="~/MasterPage/Site1.Master" %>
child.aspx.cs
((Label)this.Master.FindControl("lblsample")).Text = "Welcome ";
But, there is situation i should show master page content. so i created new webform called 'newlogin.aspx 'without master page which has head,body tag.
now if i try access master page control label in newlogin.aspx.cs, i am getting NULL reference exception.
newlogin.aspx
<%@ MasterType VirtualPath="~/MasterPage/Site1.Master" %>
newlogin.aspx.cs
((Label)this.Master.FindControl("lblsample")).Text = "Welcome ";
I am getting NULL reference exception as it is not finding.
how to access master page controls in this situation.
推荐答案
不可能!因为它们之间没有关系
No its not possible!Because there is no relationship between them
这篇关于母版页控件需要访问另一个webform而不是子页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!