【发布时间】:2018-12-14 17:56:44
【问题描述】:
我需要在触发按钮的单击事件之前调用 jquery 函数,但在我的情况下,单击事件是在调用 jquery 函数之前触发的。 我的按钮是:
<asp:Button ID="btnConfrm" runat="server" Text="View" ForeColor="Black" Width="80px" CssClass="button" Height="30px" ValidationGroup="btn" OnClientClick="ConfirmDialog()" OnClick="OnConfirm" />
JQuery 函数是:
<script type="text/javascript">
var confirm_value = document.createElement("INPUT");
confirm_value.type = "hidden";
confirm_value.name = "confirm_value";
function ConfirmDialog() {
$('<div></div>').appendTo('body')
.html('<div><h4>' + 'Do you wanto to see previous data' + '?</h4></div>')
.dialog({
modal: true, title: 'Carry forward!', zIndex: 10000, autoOpen: true,
width: 'auto', resizable: false,
buttons: {
Yes: function () {
// $(obj).removeAttr('onclick');
// $(obj).parents('.Parent').remove();
$('body').append('<h1>Confirm Dialog Result: <i>Yes</i></h1>');
$(this).dialog("close");
confirm_value.value = "Yes";
},
No: function () {
$('body').append('<h1>Confirm Dialog Result: <i>No</i></h1>');
$(this).dialog("close");
confirm_value.value = "No";
}
},
close: function (event, ui) {
$(this).remove();
}
});
document.forms[0].appendChild(confirm_value);
};
</script>
而事件是:
Public Sub OnConfirm(ByVal sender As Object, ByVal e As EventArgs) Handles btn_show.Click
Dim confirmValue As String = Request.Form("confirm_value")
Session("confirm") = confirmValue
If confirmValue = "Yes" Then
gvCustomers.Visible = True
grdblank.Visible = False
Fill_grid()
Else
gvCustomers.Visible = False
grdblank.Visible = True
'End If
End If
End Sub
我正在从 jquery 函数中获取确认值,但在按钮单击事件中值是什么。
【问题讨论】: