I have resolved it for me as below:
Jquery Code is:
$(document).ready(function () {
$('.DeleteButton').live('click', function (e) {
var td = $(this).parent('td').parent('tr');
if (confirm('Do you want to delete this record?')) {
var Index = $(this).attr('id');
var pos = Index.indexOf("_");
var position = Index.indexOf("_");
while (pos > -1) {
pos = Index.indexOf("_", pos + 1);
if (pos > -1) {
position = pos;
}
}
Index = Index.substr(position + 1);
var Id = $(this).attr('alt');
var TableName = $('[id$=hdfTableName]').val();
var PrimaryKey = $('[id$=hdfPrimaryKey]').val();
$.ajax({
type: "POST",
url: "Search.aspx/DeleteRecord",
data: "{ 'Id': '" + Id + "','TableName':'" + TableName + "','PrimaryKey':'" + PrimaryKey + "' }",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
if (msg.d == '1') {
td.hide();
$('.lblMessage').addClass("SuccessMessage");
$('.lblMessage').text('Record is deleted sucessfuly.');
$('.lblMessage').delay('5000').fadeOut('10000');
} else {
$('.lblMessage').addClass("ErrorMessage");
$('.lblMessage').text('There is some error, while deleting the record.');
$('.lblMessage').delay('5000').fadeOut('10000');
}
}
});
}
});
$('.EditButton').live('click', function (e) {
var Id = $(this).attr('alt');
window.location.href = 'Default.aspx?id=' + Id + '';
});
});
And i have called the Web Method from the page as below:
[WebMethod]
public static string DeleteRecord(string Id, string TableName, string PrimaryKey)
{
String result = "";
try
{
Id = "'" + Id + "'";
clsSearch objSearch = new clsSearch();
result = objSearch.DeleteRecord(TableName, PrimaryKey, Id);
result = "1";
}
catch (Exception ex)
{
result = ex.Message;
}
return result;
}
By the way thanks for your replies.....