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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top