Solved

ASP.NET/VB: Inserting Title with Master Page

Posted on 2014-01-28
4
290 Views
Last Modified: 2014-02-12
How can I insert the title from <%@ Page Title="" (Hello World Title) into my page?

Here is my master page:
<% @ Master Language="VB" %>
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
</head>
<body>  

<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server"></asp:ContentPlaceHolder>

</body>
</html>

Open in new window

Here is my page:

<%@ Page Title="Hello World Title" Language="VB" MasterPageFile="~/master.master" AutoEventWireup="false" %>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

<h1>Hello World</h1>

</asp:Content>

Open in new window

0
Comment
Question by:hankknight
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 83

Assisted Solution

by:CodeCruiser
CodeCruiser earned 150 total points
ID: 39814956
You have specified the Title in the page directive so that will get rendered as <title> in the head tag automatically.
0
 
LVL 15

Expert Comment

by:pateljitu
ID: 39815251
Please try code as suggested below:

For Master page:
Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
    Me.Page.Title = "Hello World Title - MASTER"
End Sub

Open in new window


For pages:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Me.Page.Title = "Hello World Title"
End Sub

Open in new window

0
 
LVL 16

Author Comment

by:hankknight
ID: 39815293
I have specified the Title in the page directive but it does not get rendered automatically.

I want the data from this to be used:
<%@ Page Title="Hello World"Why isn't it automatically working?
0
 
LVL 15

Accepted Solution

by:
pateljitu earned 350 total points
ID: 39815397
When accessing "Page" you should be seeing title as "Hello World Title".

1. What are you currently seeing when you render page? If not header add title to MASTER page and see the difference.
2. Try code-behind title change as provided earlier, just to test functionality.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question