dynamically determine the base href value

G

Guoqi Zheng

Dear sir,

On some of my pages, I used a <base href="http://www.meetholland.com/">

I need to dynamically determine the base href value to different URL based
on user session.

I am thinking to use <base id="baseUrl" runat=server>, it seems not to
work. It returns an error of missing </base> but base tag does not need
</base>

How can I achieve this?? Thannks in advanced.
 
K

Karl Seguin

Guoqi:
I agree this is a serious problem....not only does the <base> element not
"need" a closing element, it's strictly forbidden....

The only solution I can think of is that you create your own server control:

Something like:

public class HtmlBase : HtmlGenericControl {
private string href;
public string Href {
get { return href; }
set { href = value; }
}
public HtmlBase(object o) {}
protected override void Render(HtmlTextWriter writer) {
writer.Write("<base href=\"");
writer.Write(href);
writer.Write("\">");
}
}

you can then use it by
[a] registering the control:
<%@ Register TagPrefix="HtmlBase" Assembly="ASSEMBLY NAME GOES HERE"
NameSpace="NAMESPACE GOES HERE" %>

using it:
<HtmlBase:HtmlBase id="X" runat="Server" href="some value" />

Karl
 
B

bruce barker

try:

<base id="baseUrl" runat=server />

-- bruce (sqlwork.com)

| Dear sir,
|
| On some of my pages, I used a <base href="http://www.meetholland.com/">
|
| I need to dynamically determine the base href value to different URL based
| on user session.
|
| I am thinking to use <base id="baseUrl" runat=server>, it seems not to
| work. It returns an error of missing </base> but base tag does not need
| </base>
|
| How can I achieve this?? Thannks in advanced.
|
|
|
 
K

Karl Seguin

Bruce, the problem with this is that it'll get rendered as
<base href="something"></base>

but the specifications clearly state that in HTML the end tag is "forbidden"
(obviously in XHTML it's absolutely necessary).
 

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

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top