dynamically determine the base href value

Discussion in 'ASP .Net' started by Guoqi Zheng, Jan 13, 2005.

  1. Guoqi Zheng

    Guoqi Zheng Guest

    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.
    Guoqi Zheng, Jan 13, 2005
    #1
    1. Advertising

  2. Guoqi Zheng

    Karl Seguin Guest

    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



    --
    MY ASP.Net tutorials
    http://www.openmymind.net/


    "Guoqi Zheng" <> wrote in message
    news:eNe0lgY%...
    > 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.
    >
    >
    >
    Karl Seguin, Jan 13, 2005
    #2
    1. Advertising

  3. Guoqi Zheng

    bruce barker Guest

    try:

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

    -- bruce (sqlwork.com)

    "Guoqi Zheng" <> wrote in message
    news:eNe0lgY%...
    | 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.
    |
    |
    |
    bruce barker, Jan 13, 2005
    #3
  4. Guoqi Zheng

    Karl Seguin Guest

    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).

    --
    MY ASP.Net tutorials
    http://www.openmymind.net/


    "bruce barker" <> wrote in message
    news:%23bkssHZ%...
    > try:
    >
    > <base id="baseUrl" runat=server />
    >
    > -- bruce (sqlwork.com)
    >
    > "Guoqi Zheng" <> wrote in message
    > news:eNe0lgY%...
    > | 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.
    > |
    > |
    > |
    >
    >
    Karl Seguin, Jan 13, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. CRON
    Replies:
    24
    Views:
    200,645
    Adrienne Boswell
    Jun 20, 2006
  2. Soren Vejrum
    Replies:
    4
    Views:
    566
    Lasse Reichstein Nielsen
    Jul 5, 2003
  3. Vincent van Beveren

    BASE HREF and A HREF="#" onclick="..."

    Vincent van Beveren, Jul 6, 2006, in forum: Javascript
    Replies:
    2
    Views:
    310
    Vincent van Beveren
    Jul 6, 2006
  4. Thomas Bach
    Replies:
    18
    Views:
    362
    Mark Lawrence
    Aug 18, 2012
  5. MRAB
    Replies:
    0
    Views:
    134
Loading...

Share This Page