Click here to Skip to main content
15,908,013 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted

1 solution

Quote:
No its not possible!Because there is no relationship between them
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900