Hi there,
You are mixing two concepts: ASP code runs at the server while JavaScript like OnClick runs at the client. Your current code runs fine (well, at least it runs) because just before the page is sent to the browser, all ASP code is executed at the server. That's why the test method runs when you load the page.
So, they only way to access ASP code is at the server, after you have submitted the data to the server, using GET or POST.
Usually, you'll want to do something like this:
1. Add a client side handler that submits the form (like a button click, or MyForm.submit() from some JavaScript)
2. At the server, check whether the page has been submitted (that is, Request.Form("btnMyButton") has a value, for example)
3. If the page has been resubmitted, do your database insert based on the form values.
I am not sure what you mean with "I already have something occupying the ACTION form tag" Are you saying that you don't want to post to the page currently set in the action attribute?
If that's the case, you have a few options:
1. Define multiple forms on the page. Each form can have its own submit methods and action attributes.
2. Submit to another (or hidden) frame
3. Use some JavaScript to open a new page that submits a form.
HtH
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|