Adding DotNet Variables to Javascript URL

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Elmo Watson

    #1

    Adding DotNet Variables to Javascript URL

    I've got this Javascript HREF:

    <a
    href="javascrip t:void(window.o pen('print_Mile age.aspx?id=<%# sID%>&emp=<%#sE mp%>'))">Printe r
    Friendly Page</a>

    The variables sID and sEmp are populated when the page loads. However when I
    hover over the link for this, the variables are not populated in the
    querystring.
    I tried doing a Page.Databind at page_load, but I had an erroneous error
    that only disappeared once I removed the line.

    I know I've done this before, but I can't remember how - - - - What am I
    missing here?




  • Mark Rae [MVP]

    #2
    Re: Adding DotNet Variables to Javascript URL

    "Elmo Watson" <sm@here.comwro te in message
    news:u$X2GTZQIH A.2268@TK2MSFTN GP02.phx.gbl...
    I know I've done this before, but I can't remember how - - - - What am I
    missing here?
    # is Databinding shorthand... If you don't want to use that, you need to
    use:

    <a
    href="javascrip t:void(window.o pen('print_Mile age.aspx?id=<%= sID%>&emp=<%=sE mp%>'))">Printe r
    Friendly Page</a>


    --
    Mark Rae
    ASP.NET MVP


    Comment

    • Cowboy \(Gregory A. Beamer\)

      #3
      Re: Adding DotNet Variables to Javascript URL

      One option, that gives you full control, is to bind in code behind. To do
      this, use a hyperlink control instead of an anchor <a href>. It will create
      the ifno for you.

      If this is part of a grid, you can set up the hyperlink control in the grid
      and use the designer to add the information to the URL string.

      --
      Gregory A. Beamer
      MVP, MCP: +I, SE, SD, DBA

      *************** *************** *************** ****
      | Think outside the box!
      |
      *************** *************** *************** ****
      "Elmo Watson" <sm@here.comwro te in message
      news:u$X2GTZQIH A.2268@TK2MSFTN GP02.phx.gbl...
      I've got this Javascript HREF:
      >
      <a
      href="javascrip t:void(window.o pen('print_Mile age.aspx?id=<%# sID%>&emp=<%#sE mp%>'))">Printe r
      Friendly Page</a>
      >
      The variables sID and sEmp are populated when the page loads. However when
      I hover over the link for this, the variables are not populated in the
      querystring.
      I tried doing a Page.Databind at page_load, but I had an erroneous error
      that only disappeared once I removed the line.
      >
      I know I've done this before, but I can't remember how - - - - What am I
      missing here?
      >
      >
      >
      >

      Comment

      Working...