Thursday, March 22, 2012

Set Header Title from within a normal object

Is it possible to set the title for a page within a normal object; e.g.

1using System;
2using System.Web;
3using System.Web.UI;
4using System.Collections;
5using System.Web.UI.WebControls;
6using System.Web.UI.HtmlControls;
78namespace Utils
9{
10// Program start class11public class Misc
12 {
13public static void setSubject(Page page, String subject) {
14 page.Header.Title=subject;
15 }
16}

Compiling it gives me following error:

Utils.cs(16,4): error CS0117: `System.Web.UI.Page' does not contain a definition for `Header' Compilation failed: 1 error(s), 0 warnings

Thanks in advance,

jerous.

isn't it just Page.Title?

You'll need to ensure that the calling page has the runat="server" in it's <title..> tag.


Use page.Title property. It would set your page Title.

0 comments:

Post a Comment