Literals

Discussion in 'ASP .Net' started by Guest, Aug 25, 2003.

  1. Guest

    Guest Guest

    Hi,

    I am just transfering to asp.net from classic asp. I wish to write out a
    "<base href=' & servername & '>" dynaically in the head section of the
    form.
    I though at first a lieral would do the trick and that i could just set the
    text of the lieral (which server I am running on) in the page load event.

    however I found that I can't place a lieral in the head in the forms
    designer of visual studio and even if I could I guess that I would have to
    make the <form> elemants of asp.net surround the literal.

    does any body please have a solution to my problem.

    any help is appreciated.

    cheers

    martin.
    Guest, Aug 25, 2003
    #1
    1. Advertising

  2. Guest

    martin Guest

    Thank you all.


    "CT" <> wrote in message
    news:...
    > Hmm, not sure if this will do it for you, but here it goes:
    >
    > This bit goes in between the head start and end tags:
    >
    > <base id="serverNameLiteral" href="" runat="server" />
    >
    > This declaration goes in the class in your code behind file:
    >
    > protected System.Web.UI.HtmlControls.HtmlGenericControl serverNameLiteral;
    >
    > This bit goes in the Page_Load event handler in your code behind file:
    >
    > foreach (System.Web.UI.Control ParentControl in this.Page.Controls)
    > {
    > if (ParentControl.GetType().ToString() ==
    > "System.Web.UI.HtmlControls.HtmlGenericControl")
    > {
    > if (ParentControl.ID == "serverNameLiteral")
    > {
    > serverNameLiteral.Attributes["HREF"] = servername;
    > }
    > }
    > }
    >
    > I'm sure it can be done much neater, but it might be what you're after.
    > --
    > Carsten Thomsen
    > http://www.apress.com/book/bookDisplay.html?bID=105
    > <> wrote in message
    > news:%...
    > > Hi,
    > >
    > > I am just transfering to asp.net from classic asp. I wish to write

    out
    > a
    > > "<base href=' & servername & '>" dynaically in the head section of the
    > > form.
    > > I though at first a lieral would do the trick and that i could just set

    > the
    > > text of the lieral (which server I am running on) in the page load

    event.
    > >
    > > however I found that I can't place a lieral in the head in the forms
    > > designer of visual studio and even if I could I guess that I would have

    to
    > > make the <form> elemants of asp.net surround the literal.
    > >
    > > does any body please have a solution to my problem.
    > >
    > > any help is appreciated.
    > >
    > > cheers
    > >
    > > martin.
    > >
    > >

    >
    >
    martin, Aug 25, 2003
    #2
    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. Al Wilkerson

    literals

    Al Wilkerson, Sep 21, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    1,591
    Jonathan Allen
    Sep 25, 2004
  2. Replies:
    15
    Views:
    1,292
    Jerry Coffin
    Feb 1, 2005
  3. Duncan Welch

    Array of literals or better?

    Duncan Welch, Jul 27, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    308
    Duncan Welch
    Jul 27, 2004
  4. John A Grandy
    Replies:
    0
    Views:
    488
    John A Grandy
    Nov 22, 2004
  5. John Goche
    Replies:
    8
    Views:
    16,425
Loading...

Share This Page