Using Bootstrap Modal window as PartialView

后端 未结 5 1032
南方客
南方客 2020-11-27 10:05

I was looking to using the Twitter Bootstrap Modal windows as a partial view. However, I do not really think that it was designed to be used in this fashion; it seems like

5条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-27 11:03

    I do this with mustache.js and templates (you could use any JavaScript templating library).

    In my view, I have something like this:

    
    

    ...which lets me keep my templates in a partial view called Modal.ascx:

    <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
        

    I create placeholders for each modal in my view:

    <%foreach (var item in Model) {%>
        
    <%}%>
    

    ...and make ajax calls with jQuery:

    
    

    Then, you just need a trigger somewhere:

    <%foreach (var item in Model) {%>
        
            <%=Html.Encode(item.DutModel.Name)%>
        
    <%}%>
    

提交回复
热议问题