VS2003 removing "Runat" attribute from <title>

  • Thread starter Thread starter Brad
  • Start date Start date
B

Brad

I'm placing a runat=server attribute on the <title> tag in my pages, so I
can read/set the title text in code. The problem is that when I
subsequently change the page in design view VS is removing the runat=server
from the <title> tag. Unfortunately it does not do it all the time...maybe
50%.


Brad
 
I think that is just something it does unfortunately. You would either have
to keep fixing it, or keep the page in HTML view.
 
Hi,
set the runat="server" on the <head> tag and set the Title attribute as you
wish.
 
I've read about people using a placeholder instead, but I've can't seem to
figure out how to remove the <span> tags that appear in my example...
Anybody?

<title>
<asp:PlaceHolder id="ph" runat="server" />
</title>


Protected ph As WebControls.PlaceHolder

Page_Load...
Dim mylabel As New System.Web.UI.WebControls.Label
mylabel.Text = "My Title"
ph.Controls.Add(myLabel)

Greg
 
Sorry, I was working in Whidbey where this worked like a charm.

You could add a literal control to your <title> and assign the Text value of
it as you wish:
---
<head>

<title><asp:literal runat="server" id="litTitle"></asp:literal></title>

</head>

---

void Page_Load(object sender, EventArgs e)

{

litTitle.Text = "Hello, Title!";

}
 
Now that's what I was thinking of!

Jacob Munk-Stander said:
Sorry, I was working in Whidbey where this worked like a charm.

You could add a literal control to your <title> and assign the Text value of
it as you wish:
---
<head>

<title><asp:literal runat="server" id="litTitle"></asp:literal></title>

</head>

---

void Page_Load(object sender, EventArgs e)

{

litTitle.Text = "Hello, Title!";

}
 
Yep.
Happened to me too.
Real pain.

I added it to my Base class and that took care of that problem.
It is not in the designer any more.
 

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

Back
Top