誰かがこれを理解するのを手伝ってくれることを願っています。私はあちこちを見回しましたが、私を助ける例をまだ見つけていません。私はこれに非常に近いと感じています...
各行の最後にリンクボタンがある asp:gridview があります。onrowcommand を実行する前に、確認ダイアログを表示する必要があります。これが私がしなければならないコードです...何が欠けていますか?
function confirmProcessing(event) {
event.preventDefault();
$("#dialog")
.dialog({
title: "Confirm Transaction",
buttons: {
"Process": function () {
$("#dialog").dialog('close');
},
Cancel: function() {
$("#dialog").dialog('close');
return false;
}
},
close: function() {
return false;
},
modal: true,
appendTo: "form"
})
.parent()
.css('z-index', '1005');
}
aspx コード
<div class="row">
<asp:GridView runat="server" ID="ccList" CssClass="table table-striped table-responsive" ShowHeader="True" AutoGenerateColumns="False" OnRowDataBound="ccList_OnRowDataBound" OnRowCommand="ccList_OnRowCommand">
<Columns>
<asp:BoundField DataField="Street" ItemStyle-CssClass="Street" HeaderText="Street"/>
<asp:BoundField DataField="ZipCode" ItemStyle-CssClass="ZipCode" HeaderText="Zip"/>
<asp:BoundField DataField="MB4P" ItemStyle-CssClass="MB4P" HeaderText="MB4P"/>
<asp:BoundField DataField="MB4S" ItemStyle-CssClass="MB4S" HeaderText="MB4S"/>
<asp:BoundField DataField="BAL" ItemStyle-CssClass="BAL" HeaderText="BAL"/>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton runat="server" ID="btnProcess" OnClientClick="confirmProcessing(event);" Text="Process Payment" CommandName="Process" CommandArgument="<%# ((GridViewRow) Container).RowIndex %>"/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
<div id="dialog" style="display:none">
<b>Are you sure you want to process this record?</b>
</div>
OnRowCommand コード
protected void ccList_OnRowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Process")
{
//Do the processing stuff here after confirm dialog.
}
}
preventDefault を削除すると、期待される OnRowCommand が起動します。モーダル ダイアログの [プロセス] ボタンを取得してコマンドを起動する方法がわかりません...ここで何が欠けていますか?
前もって感謝します。