I want to add a RESET button in dialog box whose work is to delete the Hidden field value from database and close the dialog box:
Here is my code
<script type="text/javascript">
function OpenPopup() {
var data = document.getElementById('<%=hflinkData.ClientID %>').value;
var keyval = data.split(';');
var table = '<table>';
for (var i = 0; i < keyval.length; i++) {
var arr = keyval[i].split('=');
table += "<tr><td>" + arr[0] + "</td><td>" + arr[1] + "</td></tr>";
}
table += '</table>';
$('#WindowBody').html(table);
$('#dialogWindow').dialog({
autoOpen: false,
modal: true,
height: 200,
width: 500,
title: "Device Info",
resizable: false,
draggable: false,
position: ['center', 'center'],
closeOnEscape: true,
open: function (event, ui)
{
$('.ui-dialog').css('top', 100);
},
create: function (event) { $(event.target).parent().css('position', 'fixed'); }
});
$('#dialogWindow').dialog('open');
return false;
}
`
and this my HTML code
<div id="dialogWindow" >
<label></label>
<div id="WindowBody">
</div>
</div>`
Where "hflinkData" is the name of hidden field
Kindly use ajax post to achieve your requirement. Use normal html input button inside dialog. Kindly see the below code snippet.
<div id="dialogWindow" >
<label></label>
<div id="WindowBody">
</div>
<input type="button" onclick="deleteValue();" value="RESET" />
</div>
And send the AJAX post to code behind in 'deleteValue' method. Please see the below javascript code snippet.
<script type="text/javascript">
function deleteValue() {
$.ajax({
url: "Default.aspx/DeleteData",
type: "POST",
data: {value:$("#hflinkData").val()},
error: function (data) {
alert(data);
},
success: function (result) {
alert(result);
}
})
}
</script>
And write the required code for delete operation in code behind.
[WebMethod]
public static void DeleteData(string value)
{
//get the hidden value from parameter
//code for delete corresponding value from data base
}
Regards, Sunil Prabakar C
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.