如何更改子页面中的母版页内容? [英] How to change Master page content in child pages?
本文介绍了如何更改子页面中的母版页内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在登录应用程序
之后更改标签Login to Logout [置于母版页]并且还要更改teg a的超链接。
登录表单在内容页面中。
< div class = menu >
< ul>
< li class = login >< a href = Login.aspx >< ; asp:标签ID = lblLogin runat = server Text =登录 >< / asp:Label>< / a>< / li>
< li class = reg >< a href = Register.aspx >< asp:Label ID = lblRegister runat = server Text =注册 >< / asp:Label>< / A>< /锂>
< / ul>
< / div>
-我已将此代码放在母版页中
- 但是当用户登录子页面时,我需要更改标签文本。我无法做到,因为内容在母版页中并且在所有其他页面中保持相同。
请帮我... ..
解决方案
看到这个.. :)
如何从内容页面访问asp.net母版页控件 [ ^ ]
((标签)Master.FindControl( lblHeading ))。Text = Logout;
((主持人)Master.FindControl( ancLogin))。 href = ../ Logout.aspx;
标签masterlbllogin =(Label)Master.FindControl(lblLogin);
masterlbllogin.Text =更改文本...
标签masterlblRegister =(标签)Master.FindControl(lblRegister);
masterlblRegister .Text =更改文字......
I want to change the label Login to Logout [placed in masterpage ] after login in the application
and also want to change the hyperlink of teg a.
Login form is in Content Page..
<div class="menu"">
<ul>
<li class="login"><a href="Login.aspx"><asp:Label ID="lblLogin" runat="server" Text="Login"></asp:Label></a></li>
<li class="reg"><a href="Register.aspx"><asp:Label ID="lblRegister" runat="server" Text="Register"></asp:Label></a></li>
</ul>
</div>
-I have placed this code in Master page
-But i need to change the Text of labels when the user login on a child page. I am unable to do because the content is in master page and remain same in all other pages.
pls help me.....
解决方案
see this.. :)
How to access asp.net master page controls from content page[^]
((Label)Master.FindControl("lblHeading")).Text = "Logout"; ((Anchor)Master.FindControl("ancLogin")).href= "../Logout.aspx";
Label masterlbllogin = (Label)Master.FindControl("lblLogin"); masterlbllogin.Text = "change text..." Label masterlblRegister = (Label)Master.FindControl("lblRegister"); masterlblRegister .Text = "change text..."
这篇关于如何更改子页面中的母版页内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文