Execute a CodeBehind function from a javascript

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Here is my problem. I have a delete record button. I want to prompt the user "Do you really want to delete?". If the user clicks 'OK' then I want to execute the CodeBehind on the server side to accomplish this. How do I do this

I think the HtmlButton is probably the desired method. But, how do I get the client side javascript to execute the desired (when needed) the server side codebehind function?
 
Michael

You can do this by attatching an attribute to your server side button

In your code behind(Page_Load method)

btnDelete.Attributes.Add("onclick", "return alert('Do you really want to delete?')")

Suresh

----- Michael SL wrote: ----

Here is my problem. I have a delete record button. I want to prompt the user "Do you really want to delete?". If the user clicks 'OK' then I want to execute the CodeBehind on the server side to accomplish this. How do I do this

I think the HtmlButton is probably the desired method. But, how do I get the client side javascript to execute the desired (when needed) the server side codebehind function?
 
Back
Top