Web Connection 5.0
Re: Customizing Title
Create a property on the page class called cTitle:
cTitle = "Custom title"
You can either leave that as is or change the title then in code anywhere in the page. Here in onLoad:
FUNCTION OnLoad this.cTitle = "Today is: " + TRANS( Date() ) ENDFUNC
Then you can embed:
<head runat="server"> <title><%= this.Page.cTitle %$></title> ... </head>
+++ Rick ---
The easiest way is something like this:
<title><%= this.Page.cTitle %></title>
If you want to modify the code a bit (i just did here) you can also do the following:
Replace the wwWebHead class in webcontrol.prg with this:
************************************************************* DEFINE CLASS wwWebHead AS WWC_WEBCONTROL ************************************************************* *: Author: Rick Strahl *: (c) West Wind Technologies, 2008 *:Contact: http://www.west-wind.com *:Created: 09/21/2008 ************************************************************* #IF .F. *:Help Documentation *:Topic: Class wwWebHead *:Description: This class maps to the Page <head> tag and allows adding content to the header. NOTE this is a minimal implementation in that each of the initial header items defined in markup are not directly addressable but are rendered as a single literal. The usefulness of this control is to allow adding of content to the header at the top or bottom for things like script or CSS link injection *:Example: *:Remarks: *:SeeAlso: *:ENDHELP #ENDIF Title = "" IsContainerControl = .T. CanContainLiterals = .T. PROTECTED TopIndex TopIndex = 0 ************************************************************************ * wwWebHead :: AddControlAtTop **************************************** *** Function: Adds a control or content at the top *** Assume: *** Pass: *** Return: ************************************************************************ FUNCTION AddControlAtTop(loCtl) IF VARTYPE(loCtl) = "C" lcText = loCtl loCtl = CREATEOBJECT("wwWebLiteral") loCtl.Text = lcText ENDIF *** Insert one after the other THIS.TopIndex = THIS.TopIndex + 1 this.ChildControls.InsertAt(this.TopIndex,SYS(2015),loCtl) ENDFUNC * AddControlAtTop ************************************************************************ * wwWebHead :: AddControl **************************************** *** Function: Overload that allows passing a literal string to add to *** to the header. *** Assume: *** Pass: *** Return: ************************************************************************ FUNCTION AddControl(loCtl) IF VARTYPE(loCtl) = "C" LOCAL lcText lcText = loCtl loCtl = CREATEOBJECT("wwWebLiteral") loCtl.Text = lcText ENDIF RETURN DODEFAULT(loCtl) ENDFUNC * AddControl ************************************************************************ * wwWebHeader :: Render **************************************** *** Function: Renders the header tag and its children *** Assume: *** Pass: *** Return: ************************************************************************ FUNCTION Render() LOCAL lcContent, lcOldTitle lcContent = DODEFAULT() IF !EMPTY(THIS.Title) lcOldTitle = Extract(lcContent,"<title>","</title>",.f.,.f.,.t.) IF !EMPTY(lcOldTitle) lcContent = STRTRAN(lcContent,lcOldTitle,"<title>" + this.Title + "</title>") ENDIF ENDIF RETURN CRLF + "<head>" + lcContent + CRLF + "</head>" ENDFUNC * Render ENDDEFINE * EOC wwWebPageHeader
+++ Rick --
Dear Rick,
please, how to control web page's title?
I tried in OnLoad() with:
this.Title="test"
but Title property does not exist.
I have to set page's Title equal to a lblTitle.Text object.
Thank you very much
Once you do you can then do:
FUNCTION OnLoad() this.Header.Title = "New Title" ENDFUNC
This has been added to the core code now.
+++ Rick ---
Rick Strahl
West Wind Technologies
Making waves on the Web
West Wind Technologies
Making waves on the Web
from Maui, Hawaii