<p>I have this code in my aspx page;</p>

<pre><code>&lt;a href="javascript:void(0);" onclick=&lt;% Print(); %&gt; title="Print listings"&gt;Print&lt;/a&gt;
</code></pre>

<p>which presents a link to print a listings to a pdf when the user clicks on it; as you can note the script calls a function from the behind code.</p>

<p>The problem is that when I coded this it happens that when I go this page it prints to pdf when is loading, I thought it would wait for a click but instead it performs the printing.</p>

<p>What is the problem? thanks in advance.</p>

<p>PD. I'm working with VS2005 and for the pdf creation I use iTextSharp.</p>

Its a bit hard to tell exactly what is happening from your code snippet, but I would assume that you are outputting the pdf file to the response stream as part of the print() function.
This is will display the pdf on load because the code behind is evaluated at render time (just before it sends the code to the browser) instead of being evaluated on the client.
To get the behavior you would like the best method is to create a http handler file (ashx) that will accept any required arguments as request variables on the url and will then output the pdf to the stream.
You can then just create a href to the ashx file with the correct arguments to dispaly the document.