Adding DotNet Variables to Javascript URL

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?
 
M

Mark Rae [MVP]

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>
 
C

Cowboy \(Gregory A. Beamer\)

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top