Click here to Skip to main content
15,905,427 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I have a linkbutton on my aspx page and i want to delete the record from SQL Server
using javascript "NOT JQUERY" from ListView and then update the listview on the page.
How can it be performed?
Posted
Comments
Taha Akhtar 22-Nov-13 8:39am    
First delete the content from display from javascript
(ref: http://stackoverflow.com/questions/5933157/how-to-remove-an-html-element-using-javascript)
then call ajax to also remove it from database(ref: http://www.w3schools.com/ajax/)
ZurdoDev 22-Nov-13 8:42am    
1. jQuery is JavaScript
2. Where are you stuck?
Sumit Bhargav 22-Nov-13 8:45am    
Thanks for replying Ryan
firstly i dont think so that jquery and javascript are same.Yes they are client side scripting but are different.
I am stucked at the scripting part of javscript.What will be the code for contacting with
database and then delete it?
ZurdoDev 22-Nov-13 8:53am    
jQuery is just a library, written in JavaScript, to make using JavaScript much easier. In fact it has a method called .ajax() which is what you need to use to call a webservice. You do not want to write all the code necessary to call a webservice yourself.

1 solution

There are two ways to do it.

1. Using WebMethod :
Create webmethod to delete data from sql server and call that webmethod from javascript.
Webmethod and javascript tutorial


2. Using Generic Handler :
Create a generic handler and call that handler from javascript method.
Generic Handler Tutorial
 
Share this answer
 
Comments
Sumit Bhargav 23-Nov-13 2:06am    
Hi,thanks for replying.
I am agree with your first option but if i opt for that option i wont be able to acecess the
page controls in my webmethod function so i wont be able to bind my listview after the record
gets deleted hence it wont show the updated data in listview.
And about your second option, Can you please put some light on the javascript code to call the generic handler.
CodeBlack 23-Nov-13 11:37am    
thats true..... from webmethod you will not be able to access any serverside controls. if you want to bind your list view than you can retrieve json data from webmethod and using that json data you can bind your listview from javascript..... by the way can you tell is there any specific reason to use javascript only ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900