I have some javascript on an asp.net page code behind, but whenever the page loads, the code (response.write, and in an asp.net button click event handler), is fired.
Is this a bug? I want to only fire that response.write line of code obviously when the button is clicked, not on the page’s load. How could I achieve this?
Thanks
You have to rethink you approach completely. The way that you tried is impossible because the code doesn’t run in that order.
This is how a page is created:
The
Response.Writehappens in step 2, and the button click happens after step 5, so you would need a TARDIS to make the click affect how the page is created.