Solved

ASP.NET/VB: Inserting Title with Master Page

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
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…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

912 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now