Two methods are available for successful experiments:
Method 1.
First, on the. ASPX page:
<Head>
<Title>
<% = Pagetitle %>
</Title>
.......
</Head>
Second, on the. aspx. CS page:
Public class news_view: system. Web. UI. Page
{
............
// Used to dynamically set the page title
Protected string pagetitle;
....
Private void page_load (Object sender, system. eventargs E)
{
.......
// Dynamically set the title of the webpage as the "title" of the displayed page content"
Pagetitle = lblbiaoti. text;
...
Note: Here, lblbiaoti is a label control, Textbox Control, or other server control.
Pagetitle = lblbiaoti. Text; before a sentence, the text attribute of lblbiaoti must be assigned a value.
Method 2: Use the literal control
First, drag a literal control to the. ASPX page. Set the ID to pagetitle.
Second, go to the. aspx HTML page and add the newly added literal control'sCodeCompletely cut and paste it between <title> and </title>.
Finally, set the pagetitle value in the appropriate position on the. aspx. CS page, for example, in the pageload function.
Example:
In. aspx:
<Head>
<Title>
<Asp: literal id = "pagetitle" runat = "server"> </ASP: literal>
</Title>
In. aspx. CS:
Public class news_view: system. Web. UI. Page
{
............
// Used to dynamically set the page title
Protected string pagetitle;
....
Private void page_load (Object sender, system. eventargs E)
{
.......
// Dynamically set the title of the webpage as the "title" of the displayed page content"
Pagetitle = lblbiaoti. text;
...
Note: Here, lblbiaoti is a label control, Textbox Control, or other server control.
Pagetitle = lblbiaoti. Text; before a sentence, the text attribute of lblbiaoti must be assigned a value.