Hi
In my application i have used master page. I created a web form that DID NOT USE master page. Is it possible that from this form i can access master page controls. If yes then how can i access it?
Hi
In my application i have used master page. I created a web form that DID NOT USE master page. Is it possible that from this form i can access master page controls. If yes then how can i access it?
Short answer: a page that does not use a master page has no Master instance, so it cannot directly access master-page controls. That is what and were pointing out — Page.Master will be null when the page isn’t using a master (Page.Master documentation).
If access to the master’s UI is required, make the page use the master. Two common ways:
MasterPageFile in the page directive.MasterPageFile at runtime inside Page_PreInit (must be done in PreInit) so the Master is created for the page. See the PreInit event notes for details (Page.PreInit).Once the page has a master, prefer exposing functionality via public properties or methods on the master (or use the <%@ MasterType %> directive for a strongly-typed Master), rather than reaching into controls with FindControl. Example pattern:
Master to call that property.If converting the page to use the master is not an option, use one of these alternatives:
.ascx) and include it both in the master and in standalone pages.As concluded, switching the page to use the master (or using a shared control/service) is the practical solution.
Jump to Post— deepanbecse 0You can refer any form within the project in .net windows application but it is not possible in Web applications.I think the only solution is to use master page..
If any page is not using master page, how you can get reference? I don't think so you can do this.
You can refer any form within the project in .net windows application but it is not possible in Web applications.I think the only solution is to use master page..
ok got it..thank you all for your help
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.