如何更改文字文字 [英] how can I change the literal text

查看:95
本文介绍了如何更改文字文字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试更改文字显示的文字,但是当我更改值时,它会让任何不同。请帮助我。

例如:

我在母版页中有这个代码:



 <   fieldset  >  
< 图例 >
< asp:literal id < span class =code-keyword> = lbl_PageTitle runat = server > < / asp:literal > < / legend >
< asp:contentplaceholder id = cp runat = 服务器 >
< / asp:contentplaceholder >
< / fieldset >





和其他页面中的页面加载功能中的此代码:



  protected   void  Page_Load( object  sender,EventArgs e)
{
Helpers.InitialaizedPageTitle( this lbl_PageTitle 你好);
}





我想改变你好但是当我改变它时,没有发生......请帮助我

解决方案

为什么不写你好像

  protected   void  Page_Load( object  sender,EventArgs e)
{
lbl_PageTitle.Text = Hello;

}


您可以使用以下代码获取母版页的文字:

< pre lang =c#> Literal ltlPageTitle =(Literal)Master.FindControl( lbl_PageTitle);
ltlPageTitle.Text = 你想要的任何东西;



为此,您需要在aspx页面指令上添加以下代码:

 <% @     MasterType     VirtualPath   = 〜/ YourMaster.master < span class =code-attribute>  %>  





我希望这会有所帮助。

谢谢。


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:

<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:

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

解决方案

Why Don''t U Just Write Like

protected void Page_Load(object sender, EventArgs e)
{
lbl_PageTitle.Text="Hello";

}


You can use following code to get master page''s literal:

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:

<%@ MasterType VirtualPath="~/YourMaster.master" %>



I hope this will help.
Thanks.


这篇关于如何更改文字文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆