Um.... I'm not sure what you're trying to do in your code.
There's some very basic things to understand when doing web development:
- Some code is executed on the server. This is known as server side code. It is your C#, VB.NET, PHP code. Server side code is responsible for doing calculations, generating HTML, and sending that HTML to the web browser to display to the user.
- Client side code is executed in the web browser. This code includes things like JavaScript/Ajax. It typically works with the HTML elements that were sent to the browser so that the user doesn't have to wait for the page to post back to the server and do calculations and then return with the HTML.
With this in mind, controls like the Button have 2 aspects to them: client side and server side. When the user clicks a button, first the client side "onclick" event is executed and then (if a script doesn't stop the button from posting back to the server) the server side "onclick" event is executed.
Right now you are mixing up the two...thinking that you can call a client side code from within your server side code. But it doesn't work that way. The two are very separate!
Check out this quick over view of
How to use JavaScript in ASP.NET.
-Frinny