I have a delete button in gridview. For those who are not familiar with asp.net, my delete button gives this:
<a id="ctl00_cp1_dtgrAllRates_ctl02_lbDelete"
class="lb"
href="javascript:__doPostBack('ctl00$cp1$dtgrAllRates$ctl02$lbDelete','')">
Delete</a>
I have a confirmation dialog connected to all delete links in gridview to ask the user if they are sure that they want to delete. This is not a problem, but I want to run postback (href value) if they press confirmation. I'm not sure how to do this, since the dialog code is split into the link that is clicked, so I cannot just grab the href to 'this' for example.
var theID = $(this).attr("href");
and shoot it. Is there a way to pass href val as a parameter to the code of the dialog, or something that the “Confirm Delete” section uses it when the button is clicked, and if you click “Cancel”, the dialog just closes?
Here is my jQuery code:
$(document).ready(function(){
$("#dialog").dialog({
bgiframe: true,
autoOpen: false,
width: 400,
height: 200,
modal: true,
buttons: {
'Confirm Delete': function() {
$(this).dialog('close');
},
Cancel: function(){
$(this).dialog('close');
}
}
});
$(".lb").click(function(event){
$("#dialog").dialog('open');
event.preventDefault();
});
});
TIA
Lloyd
source
share