VB.Net Newbie question: VB.Net & Web pages

  • Thread starter Thread starter Matthew Speed
  • Start date Start date
M

Matthew Speed

How do I access the web page properties, specifically the title bar?
I want to make it so that when someone accesses my site, it says
"Welcome aaa.bbb.ccc.ddd" and fills in their IP address up in the
title bar of IE. I've figured out how to access the controls I create
myself but the browser itself eludes me.

BTW...I am doing this in VS.Net 2003 and don't want to write asp code.
I want to do this in the

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

End Sub

section of the codebehind file. I am a VB6 programmer as well as an
okay ASP programmer but I want to do drag and drop layout with VB.Net
code behind if at all possible. I figured out how to show the client
IP address in a label but I can't get it into the title.

TIA
 
Put a literal control between your <title>listeral control here</title> tags

Then you can set the title anything you want.

HTH
Brian W
 
Put a literal control between your <title>listeral control here</title> tags

Then you can set the title anything you want.

HTH
Brian W
So is it not possible to do this without directly modifying the ASP
code behind the GUI form?
 
Hi Matthew,

You can do this by using your code-behind to add client script to the page.
Once on the browser, the script will change the title. This requires that
the end user's browser allows scripting. The RegisterStartupScript function
will add the client script for you.

Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
RegisterStartupScript("title", _
"<script language=javascript>document.title='My Test Title';</script>")
End Sub

The more common way to access the title from the code-behind is to change
the HTML. Though you don't want to change the HTML, here is the technique
for your reference.

In the HTML: <title runat="server" id="MyTitle"></title>

In the code-behind:

Protected MyTitle As System.Web.UI.HtmlControls.HtmlGenericControl

Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
MyTitle.InnerHtml = "test"
End Sub

Does this answer your question?

The more typical

Thank you, Mike
Microsoft, ASP.NET Support Professional

Microsoft highly recommends to all of our customers that they visit the
http://www.microsoft.com/protect site and perform the three straightforward
steps listed to improve your computer’s security.

This posting is provided "AS IS", with no warranties, and confers no rights.


--------------------
 
Does this answer your question?
Yes it does. Thanks. I was trying to see if I would be able to use
VS.Net to do effectively identical development for web vs desktop app
and was trying to learn to do everything in code. Modifying the HTML
is certainly simpler (and does) work, I was more curious to find out
if the page object could be accessed like the rest of the objects.

Thanks for the response.
 
Matthew Speed said:
Yes it does. Thanks. I was trying to see if I would be able to use
VS.Net to do effectively identical development for web vs desktop app
and was trying to learn to do everything in code. Modifying the HTML

Have you seen this?

http://www.atozed.com/IntraWeb/Intros/DotNet.iwp

Works with ASP.net and makes developing web applications just like desktop
ones.


--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"


ELKNews - Get your free copy at http://www.atozedsoftware.com
 
I always love it when people respond with commercial responses
unrelated to a problem I am trying to solve. Now I have an address I
can filter out of my future header downloads.
 
Matthew Speed said:
I always love it when people respond with commercial responses
unrelated to a problem I am trying to solve. Now I have an address I
can filter out of my future header downloads.

There's no obligation to use it. And the user asked
"I was trying to see if I would be able to use VS.Net to do effectively
identical development "

Which is EXACTLY what it does.

It doesnt hurt to look. Its not like I responded and asked gave you some URL
to look at encryption libraries or something totally unrelated.




--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"


ELKNews - Get your free copy at http://www.atozedsoftware.com
 
Back
Top