基于Bootstarp模型窗口选择的回填父窗口控件

时间:2015-08-28 02:26:39

标签: c# jquery asp.net twitter-bootstrap model

请你帮帮我,我看了很多文章,但找不到任何解决方案。

背景:我有一个应用程序,我正在使用ASP.net webforms&引导程序。它是一个用户注册页面。

有地址控制。它还有一个按钮,可以找到匹配的地址。 用户单击匹配的地址按钮,弹出一个带有listview控件的弹出式引导窗口,其中包含所有匹配的记录,每行前面都有选择地址按钮。如果用户选择任何特定记录,则该记录值应在父窗口地址控件中更新。

问题:Bootstrap模型正确启动,带有地址列表视图和相应的选择按钮。当我按下选择按钮,代码隐藏事件正常启动时,它重置textbox1.text的值,模型窗口关闭。但我看到父窗口中的文本框没有更新。

如果我使用jquery popup模型进行复制。它工作甜美。但它不适用于bootstrap。为什么?

HTML页面:

<!-- Site Mater page -->


<link href="../Content/bootstrap.min.css" rel="stylesheet">
<script type="text/javascript" src="../scripts/jquery-1.10.2.min.js">       </script>      
<script type="text/javascript" src="../content/jquery-ui-1.11.4/jquery-  ui.js"></script>
<link href="../content/jquery-ui-1.11.4/jquery-ui.css"  rel="stylesheet" type="text/css" />
<script src="../Scripts/bootstrap.js"></script>
<script src="../Scripts/bootstrap.min.js"></script>

<asp:PlaceHolder runat="server">
    <%: Scripts.Render("~/bundles/modernizr") %>
</asp:PlaceHolder>
<webopt:bundlereference runat="server" path="~/Content/css" />
<link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />


<div class="container body-content">
<asp:ContentPlaceHolder ID="MainContent" runat="server">
</asp:ContentPlaceHolder>
 <hr />
        <footer>
            <p>&copy; <%: DateTime.Now.Year %> - My ASP.NET Application</p>
        </footer>
    </div>

</form>


 <asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent"  runat="server">

  <div>Addres1</div><asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
   <div>Addres1</div><asp:TextBox ID="TextBox2" runat="server">      </asp:TextBox>
    <div>State</div><asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
    <div>PostCode</div><asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>

 <div class="container">
 <div class="btn-group">
    <asp:Button ID="btnSubmit" class="btn-info" runat="server" Text="Submit"          
    OnClick="btnBootstrapModal_Click"></asp:Button>
</div>
</div>

<!-- Bootstrap Modal Dialog -->
<div class="modal fade" id="myModal" role="dialog" aria-    labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<asp:UpdatePanel ID="upModal" runat="server" ChildrenAsTriggers="false"  UpdateMode="Conditional">
 <ContentTemplate>
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title">Address List</h4>
                </div>
                <div class="modal-body">
                    <asp:ListView runat="server" ID="ListViewBootStrap" >
                          <LayoutTemplate>
                            <table runat="server" id="table1" >
                              <tr runat="server" id="itemPlaceholder" ></tr>
                            </table>
                          </LayoutTemplate>
                          <ItemTemplate>
                              <tr >
                              <td >
                                <asp:Label ID="NameLabel" runat="server" 
                                  Text='<%#Eval("FullAddress") %>' />
                              </td>
                              <td>
                         <asp:Button runat="server"   ID="btnSelectBootStrapAddress"
                              Text="Select" class="btn btn-default"   CommandArgument='<%# Eval("FullAddress") %>'
      OnClick="btnAddressBootStrapSelect_Click"  data-backdrop="static"  />
                              </td>
                            </tr>
                          </ItemTemplate>
                </asp:ListView>
                </div>
                <div class="modal-footer">
                    <button class="btn btn-info" data-dismiss="modal" aria-hidden="true">Close</button>
                </div>
            </div>
        </ContentTemplate>


    </asp:UpdatePanel>
</div>

代码背后的代码:

   protected void btnBootstrapModal_Click(object sender, EventArgs e)
    {

        FillMatchAddress();

        ListViewBootStrap.DataSource = objMatchAddress;
        ListViewBootStrap.DataBind();

        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "myModal", "$('#myModal').modal('show');", true);
        upModal.Update();

    }




     protected void btnAddressBootStrapSelect_Click(object sender, EventArgs e)
    {
        string FullAddress = ((System.Web.UI.WebControls.Button)(sender)).CommandArgument;
        if (FullAddress.Length != 0)
        {
            string[] arraySelectAddress = FullAddress.Split(',');
            if (arraySelectAddress.Length == 4)
            {
                TextBox1.Text = arraySelectAddress[0];
                TextBox2.Text = arraySelectAddress[1];
                TextBox3.Text = arraySelectAddress[2];
                TextBox4.Text = arraySelectAddress[3];
            }
            if (arraySelectAddress.Length == 3)
            {
                TextBox1.Text = arraySelectAddress[0];
                TextBox2.Text = "";
                TextBox3.Text = arraySelectAddress[1];
                TextBox4.Text = arraySelectAddress[2];
            }
        }


          ScriptManager.RegisterStartupScript(Page, Page.GetType(), "myModal", "$('#myModal').modal('hide');", true);

     }

我可以看到代码隐藏中的回填更新文本框值,但它不会在父窗口中更新。为什么??

请指导我

0 个答案:

没有答案