Click to See Complete Forum and Search --> : onclick event in asp


sniper
11-15-2005, 11:14 AM
How would I go about changing a javascript onclick event into asp?

sniper
11-15-2005, 11:15 AM
sorry, I forgot to give an example:

window.captureEvents(Event.CLICK)
window.onclick = clickHandler

silverbullet24
11-15-2005, 01:47 PM
depends what you're trying to do. asp is all server side so you can't only do things with asp once you post back to the page or go to another page.

why are you trying to convert from javascript to asp? you really should use both in some combination

sniper
11-15-2005, 02:09 PM
I'm not doing it by choice. I'm on internship and that's the task I was given to do. The project is redesigning an entire site for the visually impared.

Bullschmidt
11-15-2005, 05:30 PM
Related link as ASP is server-side and JavaScript is client-side:

Classic ASP Design Tips - Post Back Page
http://www.bullschmidt.com/devtip-postbackpage.asp

silverbullet24
11-15-2005, 09:59 PM
you'll have to post back to the server (and check for it) in order to use asp to do any processing. can you give a detailed example of what you need to accomplish?

redfox
11-15-2005, 10:22 PM
here is a sample that you can put in asp's code behind, not in the html
i put this in the page_load so when i load my form it will add this attribute to the btnCancel to call the function on clearTextBoxes() when i click the btnCancel

btnCancel.Attributes.Add("onClick", "javascript:clearTextBoxes();")

or you can create a function in the code behind of asp.net

Private Function blankItem(ByVal ControlName As WebControl)

ControlName.Attributes.Add("click", " blank(" + Chr(34) + ControlName.ClientID + Chr(34) + ")")

End Function
the function blank() is in javascript, i call it in asp.nets code behind, then after you set it as another function you can call that function like this

blankItem(btnCancel)


hope this will help you