Adding DotNet Variables to Javascript URL

  • Thread starter Thread starter Elmo Watson
  • Start date Start date
E

Elmo Watson

I've got this Javascript HREF:

<a
href="javascript:void(window.open('print_Mileage.aspx?id=<%#sID%>&emp=<%#sEmp%>'))">Printer
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?
 
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="javascript:void(window.open('print_Mileage.aspx?id=<%=sID%>&emp=<%=sEmp%>'))">Printer
Friendly Page</a>
 
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!
|
*************************************************
 
Back
Top