Solved

ASP.NET/VB: Inserting Title with Master Page

Posted on 2014-01-28
4
283 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

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…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 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

6 Experts available now in Live!

Get 1:1 Help Now