简体   繁体   English

如何在对话框中添加重置按钮

[英]How to add reset button in Dialog box

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: 我想在对话框中添加一个RESET按钮,其作用是从数据库中删除“隐藏字段”值并关闭对话框:

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 这是我的HTML代码

<div id="dialogWindow" >
        <label></label>
        <div id="WindowBody">
        </div>                      
    </div>`

Where "hflinkData" is the name of hidden field 其中“ hflinkData”是隐藏字段的名称

Kindly use ajax post to achieve your requirement. 请使用ajax post实现您的需求。 Use normal html input button inside dialog. 在对话框中使用普通的html输入按钮。 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. 并将AJAX帖子发送到'deleteValue'方法中的代码后面。 Please see the below javascript code snippet. 请参见下面的javascript代码段。

<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 此致Sunil Prabakar C

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM