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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running javascript before postback

Status
Not open for further replies.

sodakotahusker

Programmer
Mar 15, 2001
601
I have a delete button which is a server side control. When the user clicks that button, I want to verify on the client side that they really want to delete the record. If they say yes I want the postback to occur. If no, I want to cancel postback. Can I do this?

I know I can do this with an HTML button instead of server side and then just submit the form. However I am trying to learn ASP.NET so I'm looking for answers that go beyond just making something work.

 
Yes it can just add a onclick function to the server control like this

ctl.Attributes("onclick") = "return JSFunction();"

Then in javascript

return true to allow postback

or return false to disallow postback.

MS
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top