Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling ASP function using HTML button

Status
Not open for further replies.

SmokeyJoe

Programmer
Joined
Nov 13, 2000
Messages
80
Location
US
I have a page where I need to call an ASP function when the user presses a button. If I called it from code - No Problem. If I call a Javascript function using a button No Problem. However I cannot figure out how to call ASP functions using a button. I would think the code would be something like:

<TR><TD><INPUT TYPE = "Button" VALUE = "Do Something" ONCLICK = "<% = 'Process()' %>"></TD></TR>

Thanks for any Help

Smokey Joe
 
Simple Answer: you can't.
Complex Answer: ASP executes on the server, your code is on the client (browser), not only can the client not call a function on the server, but that code on the server executed once to create the page the browser is currently displaying and then the server code exited and cleaned up the memory, so it doesn't even exist anymore in an executable format (it would have to be called again tobe executed).

Possible Solution: You could, however, submit back to the server and have the function you need as part of the page your submitting to.

Current Error: Right now that function is getting called while the page is still being built and anything the the Process funciton outputs is probably getting spit out tight inside that OnClick. Remember, as I mentioned above, the server-side code is executed in order to build the HTML page, by the timethe user is messing with buttons and such the ASP page that created the HTML is already gone.

Note: there are some minor exceptions here and there in what I said above, but believe it as a general rule for now and worry about the exceptions later down the road.

-T

barcode_1.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top