Dynamic Title

N

niju

Hi there,
I am dynamically populating title for my web page. Here is the code
<title id="titleLabel" runat="server"></title>

Code behind
-----------
titleLabel.InnerText = myArrayList[1].ToString();

However, after compiling the page few times runat="server" disappears
and my page doesn't compile. When this happens this is what code
looks like

<title id="titleLabel" ></title>

How can I resolve this problem?
Many thanks
Niju
 
G

Guest

I'm assuming your using Visual C#?

This problem is related to the dissapearing OnInit code that occurs with
Visual C#. I had the same problem ages ago. Basically, I was told by MS that
there was a DLL problem (not one of their DLLs they were quick to point out)
that was deleting code. It's to do with the designer view.

The fix they gave me was to stop using designer view, and to change some
options. Set things like "open web pages in html view" and things like that.

Most annoying, but they assured me they wouldn't be writing a fix, so I've
been without design view for 9months. Everything is fixed in VS2005 though,
apparently.

Good luck!


Dan
 
O

Onin Tayson

You can try the code below... you won't need to declare a server side
<title> element for this code to work. Just put the code to your Page_Load
event.

string titleScript = "<script>document.title = 'Insert your title
here';</script>";
RegisterClientScriptBlock("changeTitle", titleScript);

HTH,

Onin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top