简体   繁体   English

母版页和非母版页之间的关系

[英]Relation between master page and non master page

There is a page Login.aspx having a Label control as "Lbl_LoginExpired". 有一个页面Login.aspx,其标签控件为“ Lbl_LoginExpired”。 There is also a MasterPage. 还有一个母版页。 I want to change the text of "Lbl_LoginExpired" from within the Master Page. 我想从母版页中更改“ Lbl_LoginExpired”的文本。 How can i achieve this? 我怎样才能做到这一点?

Note: 1) Login.aspx is NOT a Content page. 注意:1)Login.aspx不是内容页面。

2) Label label1=new (Label)Login.FndControl("Lbl_LoginExpired") is NOT working in MasterPage. 2) Label label1=new (Label)Login.FndControl("Lbl_LoginExpired")在MasterPage中不起作用。

If there is no master page- content relationship between these 2 pages. 如果这两个页面之间没有母版页-内容关系。 I think your options are limited. 我认为您的选择是有限的。 Also i am assuming Lbl_LoginExpired is not a part of an user control that you can register in both pages. 我也假设Lbl_LoginExpired不是可以在两个页面中注册的用户控件的一部分。 I would recommend using Session object to pass this information between these 2 pages. 我建议使用Session对象在这两个页面之间传递此信息。

Hence in your master page 因此在您的母版页中

 Session["expiredtext"] = "Your login has been expired";

And in your login pag check this session value whether it is null or not and show the content of it. 然后在您的登录页面中检查该会话值是否为null并显示其内容。

Lbl_LoginExpired.Text=Session["expiredtext"]?.ToString();

Also do not forget to reset (or abonden session when user logs out) 另外,请不要忘记重置(或在用户注销时取消会话)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM