Click here to Skip to main content
15,991,071 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi , I'm trying to change the text that literal shows but when I change the value,It doesent make any different.please help me.
for example:
I have this code in master page:

ASP.NET
<fieldset>
<legend>
<asp:literal id="lbl_PageTitle" runat="server"></asp:literal></legend>
<asp:contentplaceholder id="cp" runat="server">
</asp:contentplaceholder>
</fieldset>


and this code in page-load function in other pages:

C#
protected void Page_Load(object sender, EventArgs e)
{
Helpers.InitialaizedPageTitle(this, "lbl_PageTitle", "hello");
}


I want to change "hello" but when I change it, no happen... please help me
Posted

Why Don't U Just Write Like
C#
protected void Page_Load(object sender, EventArgs e)
{
lbl_PageTitle.Text="Hello";

}
 
Share this answer
 
You can use following code to get master page's literal:
C#
Literal ltlPageTitle= (Literal)Master.FindControl("lbl_PageTitle");
ltlPageTitle.Text = "Anything you want";

For this you need to add following code on your aspx page directive:
ASP.NET
<%@ MasterType VirtualPath="~/YourMaster.master" %>


I hope this will help.
Thanks.
 
Share this answer
 
v3
Comments
ladylove 5-Dec-12 14:30pm    
thank's for your answer...
but it doesent work.sorry,If you have time,may I send you my project that you see???
Sk. Tajbir 5-Dec-12 14:34pm    
Have you added <%@ MasterType VirtualPath="~/YourMaster.master" %> on your aspx page ? Is it giving any error ?
ladylove 5-Dec-12 14:40pm    
yes I added...No It doesnt give any error..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900