[英]How to open a popup div in Codebehind c#
在項目模板c#上打開彈出窗口。 我的問題是,當我單擊彈出窗口時,它將打開彈出窗口,但不會命中RowCommand參數(即,ecommandcommandname)。 這是代碼:
<ItemTemplate><asp:LinkButton ID="imgAppointment" Text="Appointment" runat="server" Style="float: left; margin-right: 5px;" CommandName="App" CommandArgument='<%#Eval("ID") %>' CssClass="label label-sm label-success" data-backdrop="static" data-toggle="modal" data-target="#AddTask"></asp:LinkButton></ItemTemplate>
這是關於的代碼:
protected void gvTaskDetails_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "App")
{
DataTable retval = obj.FetchAppointmentByMalmrktId(Convert.ToInt32(e.CommandArgument));
if (retval.Rows.Count > 0)
{
Repeater rptCustomers = (Repeater)Page.FindControl("rptCustomers");
rptCustomers.DataSource = retval;
rptCustomers.DataBind();
}
}
}
這是彈出的div:
<div class="modal fade " id="AddTask" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="margin-right: -15px !important;">
<div class="modal-dialog" style="margin-right: 0; width: 50%; margin-top: 0; margin-bottom: 0px; background: #fff; height: 100vh; overflow-y: auto;">
<div class="modal-header">
<div class="row">
<div class="col-sm-6">
<h3 class="text-primary text-big" style="margin-top: 0px; margin-bottom: 0px;"><b>Appointment </b></h3>
</div>
<div class="col-sm-6">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="fa fa-chevron-circle-right" id="btnAddTaskclose"></i></button>
</div>
</div>
<asp:Repeater ID="rptCustomers" runat="server">
<HeaderTemplate>
<div class="box-model">
<table class="table">
<tr>
<th style="width: 140px;">Appointment Date :
</th>
</tr>
<tr>
<th style="width: 140px;">Details :
</th>
</tr>
</table>
</div>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td style="width: 400px;">
<asp:Label ID="lbAppointmentdt" runat="server" Text='<%# Eval("Appointmentdate") %>' />
</td>
<td style="width: 400px;">
<asp:Label ID="lblDetails" runat="server" Text='<%# Eval("Details") %>' />
</td>
<td>Status
<br />
<button type="button" class="btn btn-xs btn-danger">Cancel Appointment</button>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
之三>
如果沒有其他作用,則可以嘗試手動觸發事件。 如果命令事件是您所需要的(如果我正確理解的話),則可以按以下方式觸發事件:
<script >
function myModalFunction() {
$("#AddTask").modal();
} </script>
// method to trigger an jsFunction
public void dispararJSfunction(string script)
{
try
{
Page page = HttpContext.Current.CurrentHandler as Page;
ScriptManager.RegisterStartupScript(Page, this.Page.GetType(), "its working", script, true);
}
catch (Exception ex) { Master.MostrarMsn(ex.Message, 0); }
}
protected void imgAppointment_Click(object sender, EventArgs e)
{
// script = the js modal function
dispararJSfunction("myModalFunction()");
CommandEventArgs commandArgs = new CommandEventArgs("Command Name Here", "Your Command Argument Here");
//You can pass any row
//You can also skip the row parameter and get the row from Command Argument
GridViewCommandEventArgs eventArgs = new GridViewCommandEventArgs(GridView1.Rows[0], GridView1, commandArgs);
GridView1_RowCommand(GridView1, eventArgs);
}
如果我想念什么,請告訴我。 這是我首先想到的。 我希望這可以在某種程度上幫助您。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.