473,396 Members | 1,963 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Changing document.title

Is it possible to change the document's title property from code behind (c#) ?
I need to build a dynamic title at runtime.
Nov 18 '05 #1
5 1569
Carlo Marchesoni wrote:
Is it possible to change the document's title property from code behind (c#) ?
I need to build a dynamic title at runtime.

Yes you can run any tag at the server end to turn it into an Html
Generic control:

<title id="theTitle" runat="server">

Then in your code behind you declare the title has an HtmlGenericControl
(?) and you can then do:

theTitle.Text= "my title";

I notice you posted that question 3 times... Be patient when posting to
news groups. It can take half an hour or more for your message to appear
in your mail client.

Nick...
Nov 18 '05 #2
I declared runat=server and inserted this declaration:
protected System.Web.UI.HtmlControls.HtmlGenericControl AV0010Title;

in my code behind, but there is no "Text" attribute for this at all. Which property do I have to set in order to see the Title Text.

PS: I posted three times since the Newsgroup reported an error - I don't know why.

"Nick Gilbert" wrote:
Carlo Marchesoni wrote:
Is it possible to change the document's title property from code behind (c#) ?
I need to build a dynamic title at runtime.

Yes you can run any tag at the server end to turn it into an Html
Generic control:

<title id="theTitle" runat="server">

Then in your code behind you declare the title has an HtmlGenericControl
(?) and you can then do:

theTitle.Text= "my title";

I notice you posted that question 3 times... Be patient when posting to
news groups. It can take half an hour or more for your message to appear
in your mail client.

Nick...

Nov 18 '05 #3
> I declared runat=server and inserted this declaration:
protected System.Web.UI.HtmlControls.HtmlGenericControl AV0010Title;

in my code behind, but there is no "Text" attribute for this at all. Which property do I have to set in order to see the Title Text.


Sorry - you need to use the "InnerText" property:

protected System.Web.UI.HtmlControls.HtmlGenericControl theTitle;
private void Page_Load(object sender, System.EventArgs e) {
theTitle.InnerText="foo";
}

Nick...
Nov 18 '05 #4
hi, Carlo,

my way is use Literal Control, you can put the following line inside the
<head></head>:
<title><asp:Literal id="ltTitle" runat="server"/></title>

then you can set it in your Page_load or other handler, using Text
attribute.

anyway, you should declare one relevant object in your codebehind file.

Hope it' useful to you.
I declared runat=server and inserted this declaration:
protected System.Web.UI.HtmlControls.HtmlGenericControl AV0010Title;

in my code behind, but there is no "Text" attribute for this at all. Which property do I have to set in order to see the Title Text.
PS: I posted three times since the Newsgroup reported an error - I don't know why.
"Nick Gilbert" wrote:
Carlo Marchesoni wrote:
Is it possible to change the document's title property from code behind (c#) ? I need to build a dynamic title at runtime.

Yes you can run any tag at the server end to turn it into an Html
Generic control:

<title id="theTitle" runat="server">

Then in your code behind you declare the title has an HtmlGenericControl
(?) and you can then do:

theTitle.Text= "my title";

I notice you posted that question 3 times... Be patient when posting to
news groups. It can take half an hour or more for your message to appear
in your mail client.

Nick...

Nov 18 '05 #5
BTW, if you use <title> , you should use InnerHtml instead of Text.

That is, AV0010Title.InnerHtml = "what you dynamically assign";
I declared runat=server and inserted this declaration:
protected System.Web.UI.HtmlControls.HtmlGenericControl AV0010Title;

in my code behind, but there is no "Text" attribute for this at all. Which property do I have to set in order to see the Title Text.
PS: I posted three times since the Newsgroup reported an error - I don't know why.
"Nick Gilbert" wrote:
Carlo Marchesoni wrote:
Is it possible to change the document's title property from code behind (c#) ? I need to build a dynamic title at runtime.

Yes you can run any tag at the server end to turn it into an Html
Generic control:

<title id="theTitle" runat="server">

Then in your code behind you declare the title has an HtmlGenericControl
(?) and you can then do:

theTitle.Text= "my title";

I notice you posted that question 3 times... Be patient when posting to
news groups. It can take half an hour or more for your message to appear
in your mail client.

Nick...

Nov 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Kenny | last post by:
I have been trying to write a script that will increase the size of and image when you mouse over it, and decrease it to original size, when you mouse out. After a couple of attempts, this is what...
7
by: Frostillicus | last post by:
Hi, I've written some javascript to randomly choose a classical music composer's picture and sample audio and display it on my home page (http://marc.fearby.com/), and this works fine in Mozilla...
31
by: Greg Scharlemann | last post by:
Given some recent success on a simple form validation (mainly due to the kind folks in this forum), I've tried to tackle something a bit more difficult. I'm pulling data down from a database and...
2
by: Nathan Sokalski | last post by:
I would like to change the <title></title> of a page from a user control. I have been unable to find any property in VB that allows me to do this. The only thing I have been able to find that might...
12
by: GaryDean | last post by:
In the original post I failed so indicate that I am using framework 1.1....... I need to be able to change the background color of a page from code. I found an answer to this question in...
1
by: rbinington | last post by:
Hi, I am trying to write a DNN module that has the ability to insert articles into an article repository. I want the users to be able to move pages around and enter text into the FCKEditor. I...
2
by: prash.marne | last post by:
hi guys, i have simple problem with my pop up window my code is .... <html> <head> <script type="text/javascript> function open_window(){...
3
by: bulldog8 | last post by:
I am having problems with changing a frames source file for Mozilla (1.5.0.4). The followig code works for IE: <script type="text/javascript"> var imgP = new Image(); function...
7
by: petethebloke | last post by:
Can anyone help? I have a client who has made a "dynamic interactive map" of our city using Dreamweaver. Each map file has hotspots that pop-up a div with a little image when the mouse goes over...
4
by: gubbachchi | last post by:
Hi all, Please anybody help me solve this problem. I am stuck up with this from past 2 weeks. I am developing an application where, when the user selects date from javascript datepicker and enters...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.