How to change the title of a Web Form through code?

  • Thread starter Thread starter Frank Lehmann
  • Start date Start date
F

Frank Lehmann

Hi newsgroup,

could someone please tell how to change the title of a
Web Form window through VB.NET code?

In VB 6 I would write Me.Caption="title",
and what is it in VB.NET??

Thanks for your help

Regards,
Frank
 
Look through the properties - find Text and see the value "Form1" - guess
what to do !

Me.Text="Title" - I would try that !

KS, Denmark
 
Hi Keld,

I'm afraid Me.Text=.. is impossible. Text is not a property of Me
in this context.

Regards,
Frank
 
Try this :-

In the HEAD section of the ASP.NET page (.aspx) define the title as a server
side control:

<TITLE ID=PageTitle RUNAT=server></TITLE>

.... and in the code-behind (.aspx.vb) or inline code, define ...

Protected PageTitle As New HtmlGenericControl

.... and set the title from anywhere in the code as ...

Me.PageTitle.InnerText = "Hello World"

HTH,
 
Frank Lehmann said:
I'm afraid Me.Text=.. is impossible. Text is not a property of Me
in this context.

In that case you'll have to tell us what the context is, as a form
definitely has a Text property, inherited from Control.
 
Make the <title> as a server side tag (<title runat="server">). add a HTML Generic Control in code behind with same identity of Title.

Now set the value at code behind. thats it.

HTH
Sudhakar Sadasivuni
Microsoft MVP | MCAD
www.mugh.net
www.mvpblog.com
 
I tried posting this earlier, dont know why it didn't get to the list, but
try this :-

In the HEAD section of the ASP.NET page (.aspx) define the title as a server
side control:

<TITLE ID=PageTitle RUNAT=server></TITLE>

.... and in the code-behind (.aspx.vb) or inline code, define ...

Protected PageTitle As New HtmlGenericControl

.... and set the title from anywhere in the code as ...

Me.PageTitle.InnerText = "Hello World"
 
read this

http://authors.aspalliance.com/chrisg/default.asp?article=141

--
Regards

John Timney (Microsoft ASP.NET MVP)
----------------------------------------------
<shameless_author_plug>
Professional .NET for Java Developers with C#
ISBN:1-861007-91-4
Professional Windows Forms
ISBN: 1861005547
Professional JSP 2nd Edition
ISBN: 1861004958
Professional JSP
ISBN: 1861003625
Beginning JSP Web Development
ISBN: 1861002092
</shameless_author_plug>
 
Back
Top