HTML HREF link in ASP

Discussion in 'ASP General' started by requeth@gmail.com, Aug 9, 2008.

  1. Guest

    I'm trying to do the following, but when I have the code in for hte
    HREF link I get a runtime error. How do I pass the link to the end
    user?

    <%
    Dim a as string
    Dim b as string
    a = request.browser.browser
    b = "IE"
    if a <> b then
    response.write( "You are using " & a & " to view this page. Please
    use
    Internet Explorer.")
    else


    <a href="http://example.com/index.aspx">
    <img src="./button.jpg" border="0">
    </a>


    end if
    %>
     
    , Aug 9, 2008
    #1
    1. Advertising

  2. <> wrote in message
    news:...
    > I'm trying to do the following, but when I have the code in for hte
    > HREF link I get a runtime error. How do I pass the link to the end
    > user?
    >
    > <%
    > Dim a as string
    > Dim b as string
    > a = request.browser.browser
    > b = "IE"
    > if a <> b then
    > response.write( "You are using " & a & " to view this page. Please
    > use
    > Internet Explorer.")
    > else
    >
    >
    > <a href="http://example.com/index.aspx">
    > <img src="./button.jpg" border="0">
    > </a>
    >
    >
    > end if
    > %>
    >


    Your missing a pair of %> <% around the html code.

    Note that the best place to get ASP.NET help is m.p.dotnet.framework.aspnet




    --
    Anthony Jones - MVP ASP/ASP.NET
     
    Anthony Jones, Aug 9, 2008
    #2
    1. Advertising

  3. "Mark Rae [MVP]" <> wrote in message
    news:eQmezVh%...
    > "Anthony Jones" <> wrote in message
    > news:%23egf3Gh%...
    >
    > > Note that the best place to get ASP.NET help is
    > > m.p.dotnet.framework.aspnet

    >
    > It is, but the OP's problem relates to VBScript in classic ASP...
    >


    Really? Looks like VB.NET to me.


    Dim a as string

    Above not valid in VBScript is in VB.NET


    a = response.browser.browser

    ASP Response object doesn't have a browser property. ASP.NET does.


    Use of

    <% %>

    works fine with :-

    <compilation defaultLanguage="VB">

    in the system.web section of web.config

    The only thing wrong with the code was a missing pair of %> <% around the
    html bit.


    --
    Anthony Jones - MVP ASP/ASP.NET
     
    Anthony Jones, Aug 9, 2008
    #3
  4. Gazing into my crystal ball I observed ""
    <> writing in news:38d2ab05-f778-4542-8e00-092c9ff76297
    @x35g2000hsb.googlegroups.com:

    > I'm trying to do the following, but when I have the code in for hte
    > HREF link I get a runtime error. How do I pass the link to the end
    > user?
    >
    > response.write( "You are using " & a & " to view this page. Please
    > use
    > Internet Explorer.")


    Please do not do browser sniffing. If you write your markup correctly, you
    will not have to depend on IE's buggy rendering.

    --
    Adrienne Boswell at Home
    Arbpen Web Site Design Services
    http://www.cavalcade-of-coding.info
    Please respond to the group so others can share
     
    Adrienne Boswell, Aug 9, 2008
    #4
  5. "Adrienne Boswell" <> wrote in message
    news:Xns9AF55093A8E66arbpenyahoocom@69.16.185.247...
    > Gazing into my crystal ball I observed ""
    > <> writing in news:38d2ab05-f778-4542-8e00-092c9ff76297
    > @x35g2000hsb.googlegroups.com:
    >
    > > I'm trying to do the following, but when I have the code in for hte
    > > HREF link I get a runtime error. How do I pass the link to the end
    > > user?
    > >
    > > response.write( "You are using " & a & " to view this page. Please
    > > use
    > > Internet Explorer.")

    >
    > Please do not do browser sniffing. If you write your markup correctly,

    you
    > will not have to depend on IE's buggy rendering.
    >


    Do you mean that if you write HTML correctly IE will render it correctly? ;)



    --
    Anthony Jones - MVP ASP/ASP.NET
     
    Anthony Jones, Aug 9, 2008
    #5
  6. Gazing into my crystal ball I observed "Anthony Jones"
    <> writing in
    news:uq#CIrk#:

    > "Adrienne Boswell" <> wrote in message
    > news:Xns9AF55093A8E66arbpenyahoocom@69.16.185.247...
    >> Gazing into my crystal ball I observed ""
    >> <> writing in
    >> news:38d2ab05-f778-4542-8e00-092c9ff76297
    >> @x35g2000hsb.googlegroups.com:
    >>
    >> > I'm trying to do the following, but when I have the code in for hte
    >> > HREF link I get a runtime error. How do I pass the link to the end
    >> > user?
    >> >
    >> > response.write( "You are using " & a & " to view this page. Please
    >> > use
    >> > Internet Explorer.")

    >>
    >> Please do not do browser sniffing. If you write your markup
    >> correctly,

    > you
    >> will not have to depend on IE's buggy rendering.
    >>

    >
    > Do you mean that if you write HTML correctly IE will render it
    > correctly? ;)
    >
    >
    >


    When I start designing a page, I test it in conforming browsers first,
    Opera and Firefox. Those browsers ususally get it right. Then I fix bugs
    for IE.

    But, well formed markup and valid CSS makes the process a lot easier.
    It's one of the reasons I serve conforming browsers XHTML as application
    xml+html and I serve IE HTML as text/html. That way, I know right away if
    there's an error in the markup that could foul up rendering down the line.
    --
    Adrienne Boswell at Home
    Arbpen Web Site Design Services
    http://www.cavalcade-of-coding.info
    Please respond to the group so others can share
     
    Adrienne Boswell, Aug 10, 2008
    #6
  7. "Adrienne Boswell" <> wrote in message
    news:Xns9AF674AF38AB4arbpenyahoocom@69.16.185.247...
    > Gazing into my crystal ball I observed "Anthony Jones"
    > <> writing in
    > news:uq#CIrk#:
    >
    > > "Adrienne Boswell" <> wrote in message
    > > news:Xns9AF55093A8E66arbpenyahoocom@69.16.185.247...
    > >> Gazing into my crystal ball I observed ""
    > >> <> writing in
    > >> news:38d2ab05-f778-4542-8e00-092c9ff76297
    > >> @x35g2000hsb.googlegroups.com:
    > >>
    > >> > I'm trying to do the following, but when I have the code in for hte
    > >> > HREF link I get a runtime error. How do I pass the link to the end
    > >> > user?
    > >> >
    > >> > response.write( "You are using " & a & " to view this page. Please
    > >> > use
    > >> > Internet Explorer.")
    > >>
    > >> Please do not do browser sniffing. If you write your markup
    > >> correctly,

    > > you
    > >> will not have to depend on IE's buggy rendering.
    > >>

    > >
    > > Do you mean that if you write HTML correctly IE will render it
    > > correctly? ;)
    > >
    > >
    > >

    >
    > When I start designing a page, I test it in conforming browsers first,
    > Opera and Firefox. Those browsers ususally get it right. Then I fix bugs
    > for IE.
    >
    > But, well formed markup and valid CSS makes the process a lot easier.
    > It's one of the reasons I serve conforming browsers XHTML as application
    > xml+html and I serve IE HTML as text/html. That way, I know right away if
    > there's an error in the markup that could foul up rendering down the line.


    How do you determine which browser you are serving?

    --
    Anthony Jones - MVP ASP/ASP.NET
     
    Anthony Jones, Aug 10, 2008
    #7
  8. Gazing into my crystal ball I observed "Anthony Jones"
    <> writing in
    news:#9esWdy#:

    >
    >
    > "Adrienne Boswell" <> wrote in message
    > news:Xns9AF674AF38AB4arbpenyahoocom@69.16.185.247...
    >> Gazing into my crystal ball I observed "Anthony Jones"
    >> <> writing in
    >> news:uq#CIrk#:
    >>
    >> > "Adrienne Boswell" <> wrote in message
    >> > news:Xns9AF55093A8E66arbpenyahoocom@69.16.185.247...
    >> >> Gazing into my crystal ball I observed ""
    >> >> <> writing in
    >> >> news:38d2ab05-f778-4542-8e00-092c9ff76297
    >> >> @x35g2000hsb.googlegroups.com:
    >> >>
    >> >> > I'm trying to do the following, but when I have the code in for
    >> >> > hte HREF link I get a runtime error. How do I pass the link to
    >> >> > the end user?
    >> >> >
    >> >> > response.write( "You are using " & a & " to view this page.
    >> >> > Please use
    >> >> > Internet Explorer.")
    >> >>
    >> >> Please do not do browser sniffing. If you write your markup
    >> >> correctly,
    >> > you
    >> >> will not have to depend on IE's buggy rendering.
    >> >>
    >> >
    >> > Do you mean that if you write HTML correctly IE will render it
    >> > correctly? ;)
    >> >
    >> >
    >> >

    >>
    >> When I start designing a page, I test it in conforming browsers
    >> first, Opera and Firefox. Those browsers ususally get it right.
    >> Then I fix bugs for IE.
    >>
    >> But, well formed markup and valid CSS makes the process a lot easier.
    >> It's one of the reasons I serve conforming browsers XHTML as
    >> application xml+html and I serve IE HTML as text/html. That way, I
    >> know right away if there's an error in the markup that could foul up
    >> rendering down the line.

    >
    > How do you determine which browser you are serving?
    >


    I look at the HTTP_ACCEPT string, and I also look at the UA string to
    see if it's the W3C validator. If it accepts application xml+html then
    I serve it that. IE still gets the XHTML strict doctype, but it gets
    tag soup (with croutons). With PHP, I can modify the buffer and remove
    the ending slash in elements like IMG so IE and others can get HTML, but
    I haven't found a way to do that with ASP classic - if there's a way to
    do it, I will be all ears.


    --
    Adrienne Boswell at Home
    Arbpen Web Site Design Services
    http://www.cavalcade-of-coding.info
    Please respond to the group so others can share
     
    Adrienne Boswell, Aug 11, 2008
    #8
  9. Guest

    On Aug 9, 1:54 pm, "Mark Rae [MVP]" <> wrote:
    > "Anthony Jones" <> wrote in message
    >
    > news:OUwng$h%...
    >
    > >>> Note that the best place to get ASP.NET help is
    > >>> m.p.dotnet.framework.aspnet

    >
    > >> It is, but the OP's problem relates to VBScript in classic ASP...

    >
    > > Really?  Looks like VB.NET to me.

    >
    > He made exactly the same post under the subject of "HTML Link in ASP
    > VBSCRIPT block"
    >
    > --
    > Mark Rae
    > ASP.NET MVPhttp://www.markrae.net


    That I did mark, and the link I received didnt work for me, so instead
    of reposting to aparantly the wrong group I tried posting to the
    correct one, which is supposed to be this one.
     
    , Aug 11, 2008
    #9
  10. "Adrienne Boswell" <> wrote in message
    news:Xns9AF748859F62Aarbpenyahoocom@69.16.185.247...
    > Gazing into my crystal ball I observed "Anthony Jones"
    > <> writing in
    > news:#9esWdy#:
    >
    > >
    > >
    > > "Adrienne Boswell" <> wrote in message
    > > news:Xns9AF674AF38AB4arbpenyahoocom@69.16.185.247...
    > >> Gazing into my crystal ball I observed "Anthony Jones"
    > >> <> writing in
    > >> news:uq#CIrk#:
    > >>
    > >> > "Adrienne Boswell" <> wrote in message
    > >> > news:Xns9AF55093A8E66arbpenyahoocom@69.16.185.247...
    > >> >> Gazing into my crystal ball I observed ""
    > >> >> <> writing in
    > >> >> news:38d2ab05-f778-4542-8e00-092c9ff76297
    > >> >> @x35g2000hsb.googlegroups.com:
    > >> >>
    > >> >> > I'm trying to do the following, but when I have the code in for
    > >> >> > hte HREF link I get a runtime error. How do I pass the link to
    > >> >> > the end user?
    > >> >> >
    > >> >> > response.write( "You are using " & a & " to view this page.
    > >> >> > Please use
    > >> >> > Internet Explorer.")
    > >> >>
    > >> >> Please do not do browser sniffing. If you write your markup
    > >> >> correctly,
    > >> > you
    > >> >> will not have to depend on IE's buggy rendering.
    > >> >>
    > >> >
    > >> > Do you mean that if you write HTML correctly IE will render it
    > >> > correctly? ;)
    > >> >
    > >> >
    > >> >
    > >>
    > >> When I start designing a page, I test it in conforming browsers
    > >> first, Opera and Firefox. Those browsers ususally get it right.
    > >> Then I fix bugs for IE.
    > >>
    > >> But, well formed markup and valid CSS makes the process a lot easier.
    > >> It's one of the reasons I serve conforming browsers XHTML as
    > >> application xml+html and I serve IE HTML as text/html. That way, I
    > >> know right away if there's an error in the markup that could foul up
    > >> rendering down the line.

    > >
    > > How do you determine which browser you are serving?
    > >

    >
    > I look at the HTTP_ACCEPT string, and I also look at the UA string to
    > see if it's the W3C validator. If it accepts application xml+html then
    > I serve it that. IE still gets the XHTML strict doctype, but it gets
    > tag soup (with croutons).


    Tag soup? Don't you just send the XHTML but leave the content type as
    text/html?

    I'm still not sure how you are differentiating IE from other browsers with
    this or how by generating 'correct' HTML you manage to avoid IE messing up
    the rendering due to its bugs?

    >With PHP, I can modify the buffer and remove
    > the ending slash in elements like IMG so IE and others can get HTML, but
    > I haven't found a way to do that with ASP classic - if there's a way to
    > do it, I will be all ears.
    >


    I'm not sure I understand why you would want to? I send the xhtml content
    as text/html without that sort of mucking about, I've not had any problems
    with it.


    --
    Anthony Jones - MVP ASP/ASP.NET
     
    Anthony Jones, Aug 11, 2008
    #10
  11. <> wrote in message
    news:...
    On Aug 9, 1:54 pm, "Mark Rae [MVP]" <> wrote:
    >>>

    >
    >
    > He made exactly the same post under the subject of "HTML Link in ASP
    > VBSCRIPT block"
    >


    That I did mark, and the link I received didnt work for me, so instead
    of reposting to aparantly the wrong group I tried posting to the
    correct one, which is supposed to be this one.
    <<<

    In that case my comments re the %> <% stand but in addition.

    This:-

    Dim a as string
    Dim b as string

    Should become:-

    Dim a
    Dim b

    Also the Request object doesn't have a browser property.

    You could sniff the User-Agent header:-

    a = Request.ServerVariables("HTTP_USER_AGENT")
    b = "MSIE"

    If Instr(a, b) = -1 Then
    response.write( "You are using " & a & " to view this page. Please use
    Internet Explorer.")
    else
    %>

    <a href="http://example.com/index.aspx">
    <img src="./button.jpg" border="0">
    </a>

    <%
    end if
    %>


    I hope this if for an intranet project, if I arrived at a public site that
    said that I needed to use IE to view its content I probably wouldn't bother
    with it.



    --
    Anthony Jones - MVP ASP/ASP.NET
     
    Anthony Jones, Aug 11, 2008
    #11
  12. Anthony Jones wrote:
    > This:-
    >
    >> Dim a as string
    >> Dim b as string


    ....Looks like VB.NET.

    And...


    > Also the Request object doesn't have a browser property.


    ....except here:

    http://msdn.microsoft.com/en-us/library/system.web.httprequest_properties.aspx

    The OP does not know the difference between ASP and ASP.NET.



    --
    Dave Anderson

    Unsolicited commercial email will be read at a cost of $500 per message. Use
    of this email address implies consent to these terms.
     
    Dave Anderson, Aug 11, 2008
    #12
  13. "Dave Anderson" <> wrote in message
    news:%23WeCOZ$%...
    > Anthony Jones wrote:
    > > This:-
    > >
    > >> Dim a as string
    > >> Dim b as string

    >
    > ...Looks like VB.NET.
    >
    > And...
    >
    >
    > > Also the Request object doesn't have a browser property.

    >
    > ...except here:
    >
    >

    http://msdn.microsoft.com/en-us/library/system.web.httprequest_properties.aspx
    >
    > The OP does not know the difference between ASP and ASP.NET.
    >
    >



    Yes, I orriginaly indicated that in an earlier reply but the OP has since
    indicated that VBScript is intended.


    --
    Anthony Jones - MVP ASP/ASP.NET
     
    Anthony Jones, Aug 12, 2008
    #13
  14. Gazing into my crystal ball I observed "Anthony Jones"
    <> writing in
    news:eEQqsM$#:

    >> I look at the HTTP_ACCEPT string, and I also look at the UA string to
    >> see if it's the W3C validator. If it accepts application xml+html
    >> then I serve it that. IE still gets the XHTML strict doctype, but it
    >> gets tag soup (with croutons).

    >
    > Tag soup? Don't you just send the XHTML but leave the content type as
    > text/html?
    >
    > I'm still not sure how you are differentiating IE from other browsers
    > with this or how by generating 'correct' HTML you manage to avoid IE
    > messing up the rendering due to its bugs?
    >
    >>With PHP, I can modify the buffer and remove
    >> the ending slash in elements like IMG so IE and others can get HTML,
    >> but I haven't found a way to do that with ASP classic - if there's a
    >> way to do it, I will be all ears.
    >>

    >
    > I'm not sure I understand why you would want to? I send the xhtml
    > content as text/html without that sort of mucking about, I've not had
    > any problems with it.
    >
    >


    If you go over to alt.html, there are plenty of references why it is not
    advisable to serve XHTML as text/html - and here's a link with a lot of
    information: http://hixie.ch/advocacy/xhtml
    --
    Adrienne Boswell at Home
    Arbpen Web Site Design Services
    http://www.cavalcade-of-coding.info
    Please respond to the group so others can share
     
    Adrienne Boswell, Aug 12, 2008
    #14
  15. Adrienne Boswell" <> wrote in message
    news:Xns9AF83E4A7AB4Barbpenyahoocom@69.16.185.250...
    > Gazing into my crystal ball I observed "Anthony Jones"
    > <> writing in
    > news:eEQqsM$#:
    >
    > >> I look at the HTTP_ACCEPT string, and I also look at the UA string to
    > >> see if it's the W3C validator. If it accepts application xml+html
    > >> then I serve it that. IE still gets the XHTML strict doctype, but it
    > >> gets tag soup (with croutons).

    > >
    > > Tag soup? Don't you just send the XHTML but leave the content type as
    > > text/html?
    > >
    > > I'm still not sure how you are differentiating IE from other browsers
    > > with this or how by generating 'correct' HTML you manage to avoid IE
    > > messing up the rendering due to its bugs?
    > >


    Do you have an answer to this question?

    > >>With PHP, I can modify the buffer and remove
    > >> the ending slash in elements like IMG so IE and others can get HTML,
    > >> but I haven't found a way to do that with ASP classic - if there's a
    > >> way to do it, I will be all ears.
    > >>

    > >
    > > I'm not sure I understand why you would want to? I send the xhtml
    > > content as text/html without that sort of mucking about, I've not had
    > > any problems with it.
    > >
    > >

    >
    > If you go over to alt.html, there are plenty of references why it is not
    > advisable to serve XHTML as text/html - and here's a link with a lot of
    > information: http://hixie.ch/advocacy/xhtml



    Yes I've read this document before. Some of the more human arguments are
    valid (re imagining the content is XHTML when in fact there are often many
    practices which break if you actually sent it as xml).

    However its also overly purist IMO. Have you actually seen an example of
    the /> 'problem' in the real world?

    Even when I use HTML 4.0 strict I'll still send the html as if it were well
    formed XML with <br /> etc since I work with both XML a great deal I find it
    hard to look at HTML that breaks XML rules. I never found an occasion
    where HTML that does conform to XML rules to fail to render correctly.


    --
    Anthony Jones - MVP ASP/ASP.NET
     
    Anthony Jones, Aug 12, 2008
    #15
  16. Adrienne Boswell wrote:
    > If you go over to alt.html, there are plenty of references why it is
    > not advisable to serve XHTML as text/html - and here's a link with a
    > lot of information: http://hixie.ch/advocacy/xhtml


    Not all of it correct. For example,

    browsers treat the string "<br/>" as "<br>" and not "<br>&gt;",
    the latter being what HTML4/SGML says they should do.
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    The HTML 4.01 specification does not state that this *should* render the
    same way as SGML. On the contrary, it takes no stand other than to warn that
    SHORTTAG constructs for elements are likely unsupported:
    http://www.w3.org/TR/html401/appendix/notes.html#h-B.3.7



    --
    Dave Anderson

    Unsolicited commercial email will be read at a cost of $500 per message. Use
    of this email address implies consent to these terms.
     
    Dave Anderson, Aug 12, 2008
    #16
    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:
    203,763
    Adrienne Boswell
    Jun 20, 2006
  2. Soren Vejrum
    Replies:
    4
    Views:
    763
    Lasse Reichstein Nielsen
    Jul 5, 2003
  3. saiho.yuen
    Replies:
    3
    Views:
    549
    kaeli
    Sep 14, 2004
  4. Replies:
    2
    Views:
    628
  5. Vincent van Beveren

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

    Vincent van Beveren, Jul 6, 2006, in forum: Javascript
    Replies:
    2
    Views:
    427
    Vincent van Beveren
    Jul 6, 2006
Loading...

Share This Page