如何从后面的代码中调用modalpopup扩展器

时间:2019-05-03 10:44:09

标签: asp.net c#-4.0 updatepanel modalpopupextender

我有一个网格视图,其中显示了列出的订户。现在,当用户单击编辑链接时,一个模式弹出扩展器会显示带有订户详细信息的面板。它曾经显示BackBackground样式,但从未显示面板内容。这是我的代码:

protected void gvSubscribers_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "edits")
        {
            int id = Convert.ToInt32(e.CommandArgument);
            hd_SUBID.Value = id.ToString();
            MPE1.Show();
            myModal_autocomplete.Style.Add("display", "block"); //here I change this style attribute to show panel contents
            DataTable dt = new DataTable();
            string str = "SELECT [Name],[EmailAddress],[MobileNo],[category_id] FROM [dbo].[tbl_Subscribers] s WHERE Id='" + id + "'";
            dt = obj.Get_Data_Table_From_Str(str);
            txt_subcribername.Text = dt.Rows[0]["Name"].ToString().Trim();
            txt_subscriberemail.Text = dt.Rows[0]["EmailAddress"].ToString().Trim();
            txt_subscribermobile.Text = dt.Rows[0]["MobileNo"].ToString().Trim();
            DAL_ComboFill obj_u = new DAL_ComboFill();
            obj_u.Fill_SubscriberCategories_Combo(this, DDL_CategoryList, false, false, int.Parse(CommonLogic.GetSessionValue("type_id").ToString()), int.Parse(CommonLogic.GetSessionValue("user_id").ToString()));
            DDL_CategoryList.SelectedValue = dt.Rows[0]["category_id"].ToString().Trim();
        }
}

这是我的模式弹出窗口扩展程序标记:

<ajaxToolkit:ModalPopupExtender ID="MPE1" runat="server"
                                                     BackgroundCssClass="modal-backdrop fade in" CancelControlID="btnclose"
                                                     Enabled="True" PopupControlID="myModal_autocomplete"
                                                     TargetControlID="hd">
                                                 </ajaxToolkit:ModalPopupExtender>

最后是我的面板标记:

<div id="myModal_autocomplete" class="modal fade in" style="display:none; padding-right: 17px;" runat="server">
        <asp:HiddenField ID="hd_SUBID" runat="server" />
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <asp:Button ID="btnclose" runat="server" CssClass="close"/>
                    <h4 class="modal-title">Subscriber Edit</h4>
                </div>
                <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
                    <ContentTemplate>
                <div class="modal-body form">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">Name</label>
                        <div class="col-sm-8">
                            <div class="input-group">
                                <asp:TextBox ID="txt_subcribername" runat="server" CssClass="form-control tt-input" ValidationGroup="EditSubscriber"></asp:TextBox>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label">Email</label>
                        <div class="col-sm-8">
                            <div class="input-group">
                                <asp:TextBox ID="txt_subscriberemail" runat="server" CssClass="form-control tt-input" ValidationGroup="EditSubscriber"></asp:TextBox>
                            </div>
                        </div>
                    </div>
                     <div class="form-group">
                        <label class="col-sm-4 control-label">Mobile No</label>
                        <div class="col-sm-8">
                            <div class="input-group">
                                <asp:TextBox ID="txt_subscribermobile" runat="server" CssClass="form-control tt-input" ValidationGroup="EditSubscriber"></asp:TextBox>
                            </div>
                        </div>
                    </div>
                     <div class="form-group">
                        <label class="col-sm-4 control-label">Category</label>
                        <div class="col-sm-8">
                            <div class="input-group">
                                <asp:DropDownList ID="DDL_CategoryList" runat="server" AutoPostBack="true" ValidationGroup="EditSubscriber" CssClass="form-control tt-input" OnSelectedIndexChanged="DDL_CategoryList_SelectedIndexChanged" ></asp:DropDownList>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <asp:Button ID="btn_close" runat="server" Text="Close"  CssClass="btn grey-salsa btn-outline" OnClick="btn_close_Click"/>
                    <asp:Button ID="btn_update" runat="server" Text="Save changes"  CssClass="btn green"/>
                </div>
                    </ContentTemplate>
                    <Triggers>
                        <asp:AsyncPostBackTrigger ControlID="DDL_CategoryList" EventName="SelectedIndexChanged" />
                        <asp:AsyncPostBackTrigger ControlID="btn_close" EventName="Click" />
                        <asp:AsyncPostBackTrigger ControlID="btn_update" EventName="Click" />
                    </Triggers>
                </asp:UpdatePanel>
            </div>
        </div>
            </div>

这将显示面板内容几秒钟,然后消失这里的问题。请帮帮我。.

0 个答案:

没有答案