We have a web site built in C# / ASP.NET
Currently we have one title that applies for all pages so if you navigate to each of the pages of
http://www.m-photo.com you can verify that the title remains the same.
We want a script that will change the title dynamically so if for example I navigate to :
http://www.m-photo.com/products/backend/And I press on each of the products located in the left menu I will get a page with a different title according to the ID
For example
http://www.m-photo.com/products/backend/default.aspx?ProdID=9 (title 1)
http://www.m-photo.com/products/backend/default.aspx?ProdID=10 (title 2)
Etc&
This is the code of our Portal. Master page (the main template)
<%@ Master Language="C#" AutoEventWireup="true" %>
<%@ Import namespace="System" %>
<%@ Import namespace="System.Text" %>
<%@ Import namespace="System.Configur
ation" %>
<%@ Import namespace="System.Collecti
ons.Generi
c" %>
<%@ Import namespace="System.Web" %>
<%@ Import namespace="System.Web.Secu
rity" %>
<%@ Import namespace="System.Web.UI" %>
<%@ Import namespace="System.Web.UI.W
ebControls
" %>
<%@ Import namespace="System.Web.UI.W
ebControls
.WebParts"
%>
<%@ Import namespace="System.Web.UI.H
tmlControl
s" %>
<%@ Import namespace="System.Data" %>
<%@ Import namespace="System.Data.Sql
Client" %>
<%@ Register src="~/App_Controls/suppor
t.ascx" tagname="support" tagprefix="uc1" %>
<%@ Register src="~/App_Controls/TopMen
u.ascx" tagname="TopMenu" tagprefix="uc2" %>
<%@ Register src="~/App_Controls/News.a
scx" tagname="News" tagprefix="uc3" %>
<%@ Register src="~/App_Controls/footer
.ascx" tagname="footer" tagprefix="uc4" %>
<%@ Register src="~/App_Controls/copyri
ght.ascx" tagname="copyright" tagprefix="uc5" %>
<script runat="server">
//Constants defining title for "unnamed" page and
const string DEFAULT_UNNAMED_PAGE_TITLE
= "Untitled Page";
const string DEFAULT_PAGE_TITLE = "M-Photo Ltd. - Color correction tools for professional photolabs";
protected void Page_Load(object sender, System.EventArgs e)
{
//Set the page's title, if needed
if (string.IsNullOrEmpty(Page
.Title) || Page.Title == DEFAULT_UNNAMED_PAGE_TITLE
)
{
Page.Title = DEFAULT_PAGE_TITLE;
}
}
</script>
This is the code of one of the default.aspx (in this case it is the
http://www.m-photo.com/products/backend/)
<%@ Page Language="C#" MasterPageFile="~/App_Mast
ers/Portal
.Master" AutoEventWireup="true" Theme="Standard" Buffer="true" %>
<%@ Register Src="~/App_Controls/front.
ascx" TagName="front" TagPrefix="uc1" %>
<asp:Content ID="Content1" runat="server" contentplaceholderid="midP
an">
<asp:Repeater id="Repeater1" runat="server" DataSourceID="dsGeneral">
<ItemTemplate>
<h2><%# DataBinder.Eval(Container.
DataItem, "title")%></h2>
<%# DataBinder.Eval(Container.
DataItem, "full_text")%>
</ItemTemplate>
</asp:Repeater><asp:SqlDat
aSource id="dsGeneral" runat="server" ConnectionString="<%$ ConnectionStrings:portalDS
N %>" SelectCommand="sp_get_Prod
uctsByID" SelectCommandType="StoredP
rocedure">
<SelectParameters>
<asp:QueryStringParameter Name="ProdID" QueryStringField="ProdID"
Type="Int32" DefaultValue="1" />
<asp:Parameter DefaultValue="2" Name="ProdCatID" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</asp:Content>
<asp:Content ID="Content2" runat="server" ContentPlaceHolderID="left
Pan">
<uc1:front ID="front1" runat="server" />
</asp:Content>