从另一个母版页找到母版页控件?

时间:2022-10-19 23:29:01

I am using two Different master page in my site. On one master page i am using a LoginStatus control. So wanna access that LoginStatus control from other. I have no great knowledge about how to find the controls from one master page to other.

我在我的网站中使用两个不同的母版页。在一个母版页上,我使用的是LoginStatus控件。所以想从其他人访问LoginStatus控件。我不知道如何从一个母版页找到其他母版页。

Is there any way to achieving this. Any help is deeply appreciated. Thanks.

有没有办法实现这一目标。非常感谢任何帮助。谢谢。

2 个解决方案

#1


1  

Well if there is single master page and content page you can access control using

好吧,如果有单个母版页和内容页面,您可以使用访问控制

  Label lblinMaster = (Label)This.Master.FindControl("Label1");

and the same way to access control in nested master page you can use following.

和嵌套母版页中的访问控制相同,您可以使用以下方法。

Label lblinParentMaster = (Label)Master.Master.FindControl("Label1");

Hope this helps.

希望这可以帮助。

#2


0  

Unless you are using nested master pages, you cannot access one master page from another.
A Page would normally use only one master page at a time.

除非您使用嵌套母版页,否则无法从另一个母版页访问一个母版页。页面通常一次只使用一个母版页。

The users login status, however is not dependent on the LoginStatus control. You can show this status everywhere.

但是,用户登录状态不依赖于LoginStatus控件。您可以随处显示此状态。

Refer: ASP.NET Login Controls to get an idea about the right control to use.

请参阅:ASP.NET登录控件以了解要使用的正确控件。

#1


1  

Well if there is single master page and content page you can access control using

好吧,如果有单个母版页和内容页面,您可以使用访问控制

  Label lblinMaster = (Label)This.Master.FindControl("Label1");

and the same way to access control in nested master page you can use following.

和嵌套母版页中的访问控制相同,您可以使用以下方法。

Label lblinParentMaster = (Label)Master.Master.FindControl("Label1");

Hope this helps.

希望这可以帮助。

#2


0  

Unless you are using nested master pages, you cannot access one master page from another.
A Page would normally use only one master page at a time.

除非您使用嵌套母版页,否则无法从另一个母版页访问一个母版页。页面通常一次只使用一个母版页。

The users login status, however is not dependent on the LoginStatus control. You can show this status everywhere.

但是,用户登录状态不依赖于LoginStatus控件。您可以随处显示此状态。

Refer: ASP.NET Login Controls to get an idea about the right control to use.

请参阅:ASP.NET登录控件以了解要使用的正确控件。