且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何更改子页面中的母版页内容?

更新时间:2023-09-20 13:02:16

看到这个.. :)



如何从内容页面访问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..."