How to add <base target="_self"> in code behind

J

Joe Kovac

Hi!

I want to add
<base target="_self">
into the header section of a aspx page. I want to do this in the code
behind because I use master pages which I do not want to change directly.

Thanks

Joe
 
G

Guest

Another option:

Have a protected class-level string variable (and assign a value in
Page_Load or inline) in the code-behind:

protected string baseUrl = "<base href=\"_self\">";

And in the .aspx page:

<head>
<%= baseUrl %>
</head>
 
J

Joe Kovac

Mark said:
In the MasterPage...

Well, I don't want this in the MasterPage as not all pages are
concerned. Therefor I use:

Page.Header.Controls.Add(new LiteralControl(@"<base target=""_self"" />"));
 
M

Mark Rae

Well, I don't want this in the MasterPage as not all pages are concerned.
Therefor I use:

Page.Header.Controls.Add(new LiteralControl(@"<base target=""_self""
/>"));


Indeed - what I meant was that such things need to end up in the header
section and, since content pages don't have headers...

No biggie...
 

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

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,835
Latest member
KetoRushACVBuy

Latest Threads

Top