Using bootstrap modalpopup in ASP.NET

自古美人都是妖i 提交于 2019-12-10 22:30:39

问题


I have a Products page which displays a list of products. When i click Details button, i want to show product details in a bootstrap modal popup.

I want to get one of the product detail but this code gets all products details.

how can i fix this query:

.aspx code:

<asp:Repeater ID="rpProducts" runat="server">
<ItemTemplate>
     <td> <div class="btn-ud" ><a href="<%#Eval("ProductID") %>" data-toggle="modal" data-target="#myModal2" class="btn btn-custom-3 btn-sm"/ >Details</a> </div> </td> 
</ItemTemplate>
</asp:Repeater>

modal popup code:

<div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-hidden="true">
<asp:Repeater ID="rpProductDetails" runat="server">
<ItemTemplate>
<tbody>
<td height="100px"> <%#Eval("ProductDetails")%> </td>
<td height="100px">  <%#Eval("ProductDetails")%> </td>
</tbody>
</ItemTemplate>
</asp:Repeater>      
</div>    

c# code:

DataTable dtProductsDetails = system.GetDataTable("Select ProductDetails,TechDetails,Standards, ApplicationArea from TBLPRODUCTS where ProductID = ProductID");
          if (dtProductsDetails.Rows.Count > 0)
          {
              rpProductDetails.DataSource = dtProductsDetails;
              rpProductDetails.DataBind();
          }

回答1:


    <script type="text/javascript">
      function openModal() {
      $('#myModal').modal('show');
    }
    </script>

In your c# code add an event for linkbutton like

    protected void lbEdit_Click(object sender, EventArgs e) {   
     ScriptManager.RegisterStartupScript(this,this.GetType(),"Pop","openModal();", true);
    }



回答2:


You have to use jQuery for this:

$("a").click(function(){
    $("#myModal2").modal("show");
});


来源:https://stackoverflow.com/questions/35312965/using-bootstrap-modalpopup-in-asp-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!