Solved

ASP.NET/VB: Inserting Title with Master Page

Posted on 2014-01-28
4
287 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
  • 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

821 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