关闭弹出窗口后刷新jquery弹出窗口

时间:2014-08-16 08:57:55

标签: c# javascript jquery asp.net bootstrap-modal

单击一个asp按钮后弹出模态:

<div class="form-group">
     <asp:Button ID="btnBrand" runat="server" Text="Add brand" CssClass="btn btn-info" OnClick="btnAdd_Click" />
</div>

代码背后:

protected void btnAdd_Click(object sender, EventArgs e) //Open Model popup
{
   System.Text.StringBuilder sb = new System.Text.StringBuilder();
   sb.Append(@"<script type='text/javascript'>");
   sb.Append("$('#addModal').modal('show');");
   sb.Append(@"</script>");
   ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "AddShowModalScript", sb.ToString(), false);
}

我的弹出模式html:

    <div id="addModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="addModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h3 id="addModalLabel">Add brand details</h3>
            </div>

            <asp:UpdatePanel ID="updAdd" runat="server">
                <ContentTemplate>
                    <div class="modal-body">
                        <div class="form-horizontal">
                            <div class="form-group" title="Code">
                                <div class="input-group FullWidth ">
                                    <label for="Code" class="col-sm-2 control-label">Code</label>
                                    <div class="col-sm-10">
                                        <asp:TextBox ID="txtCodeAdd" runat="server" CssClass="form-control" MaxLength="10" onchange="OnTextChanged()" ToolTip="Colour Code" ValidationGroup="Save"></asp:TextBox>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group" title="Vendor">
                                <div class="input-group FullWidth">
                                    <label for="Code" class="col-sm-2 control-label">Vendor</label>
                                    <div class="col-sm-5">
                                        <asp:TextBox ID="txtVendorAdd" runat="server" MaxLength="20" CssClass="form-control" ToolTip="Vendor" ReadOnly="true"></asp:TextBox>
                                    </div>
                                    <div class="col-sm-5 row form-inline">
                                        <asp:Button ID="btnLookup" runat="server" Text="Lookup" CssClass="btn btn-info" OnClientClick="openLookup()" />
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="modal-footer">
                        <button class="btn btn-info" data-dismiss="modal" aria-hidden="true">Close</button>
                    </div>
                </ContentTemplate>

                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="btnAddRecord" EventName="Click" />
                </Triggers>

            </asp:UpdatePanel>
        </div>
    </div>
</div>

在这个弹出模式中会触发新的窗口查找页面,我的apsx查找页面如下:

    <asp:UpdatePanel ID="upVendorLookup" runat="server">

    <ContentTemplate>

        <asp:GridView ID="grdVendor" runat="server" Width="100%" HorizontalAlign="Center"
            AutoGenerateColumns="false" AllowPaging="True"
            DataKeyNames="ID" CssClass="table table-condensed" GridLines="None"
            OnPageIndexChanging="grdVendorPageIndexChanging">

            <Columns>
                <asp:TemplateField HeaderText="Select">
                        <ItemTemplate>
                                <input name="rdVendor" type="radio" value='<%# Eval("ID") %>' />
                        </ItemTemplate>
                    </asp:TemplateField>
                <asp:BoundField DataField="ID" HeaderText="ID" />
                <asp:BoundField DataField="Code" HeaderText="Code" />
                <asp:BoundField DataField="Name" HeaderText="Name" />
                <asp:BoundField DataField="Tel1" HeaderText="Tel#1" />
                <asp:BoundField DataField="Tel2" HeaderText="Tel#2" />
            </Columns>
        </asp:GridView>

        <asp:Button ID="btnSelect" runat="server" Text="Select" CssClass="btn btn-info" OnClick="btnSelectVendor" />
    </ContentTemplate>

</asp:UpdatePanel>

代码背后:

    protected void btnSelectVendor(object sender, EventArgs e)
    {
        string selectedValue = Request.Form["rdVendor"];

        HttpContext.Current.Items["rdVendor"] = selectedValue;
        Server.Transfer("../CodeEntry/Brand.aspx");
    }

如何将选定的vendorID传回Brand.aspx并刷新弹出模式,然后将vendorID值设置为弹出模式中的文本框?并关闭了弹出窗口..

是否可以这种方式实施?

我现在正在使用HttpContext,并且能够从brand.aspx获取pageload函数中的vendorID,但无法将vendorID设置为弹出模式..

protected void Page_Load(object sender, EventArgs e)
{
        if (!Page.IsPostBack)
        {
            string test = (String)HttpContext.Current.Items["rdVendor"];
            txtVendorAdd.Text = test;
        }
}

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

如果使用以下方法启动模式弹出窗口,它将使您完全控制在父级和弹出窗口之间传递值。 http://02e34b5.netsolhost.com/youtube/Zpopup.aspx