【问题标题】:HOW TO PASS A PARAMTER TO AN ASP MODAL USER CONTROL如何将参数传递给 ASP 模态用户控件
【发布时间】:2015-02-09 06:56:26
【问题描述】:

-- 我如何在这段代码中使下一句使用参数而不是 CURRENT_USER.ACCOUNID MediaSuite.Web.UI.Code.CurrentUser)Session["current_user"]).AccountId

-- 显然在调用模态之前,我如何从 Javascript 传递该参数

<% var accountAlerts = MediaSuite.BusinessLayer.Accounts.AccountAlertRecord.GetRecords(((MediaSuite.Web.UI.Code.CurrentUser)Session["current_user"]).AccountId).Data; %>
<div class="modal hide fade" id="accountSetAlertsModal" style="width:500px;height:600px;overflow:hidden;">
<% using (Html.BeginForm("SetAlerts", "Accounts", null, FormMethod.Post, new { @id = "AccountSetAlertsModal" }))
   { %>
    <div class="modal-header" >
        <div class="navbar navbar-static navbar_as_heading">
            <div class="navbar-inner">
                <div class="container" style="width: auto; color: White; font-family: sans-serif; font-size: 2em; padding-top: 10px" >
                    <!-- <button type="button" class="icon-remove-sign" data-dismiss="modal" aria-hidden="true">&times;</button> -->
                    <span style="float:left;margin-left:2px;margin-top:3px;">
                        Set Alerts
                    </span>
                    <span class="icon-remove-sign" data-dismiss="modal" aria-hidden="true" 
                        style="float:right;margin-right:10px;cursor:pointer;"></span>
                </div>    
            </div>
        </div>           
    </div>
    <div class="modal-body"> 
            <table cellpadding="15px" cellspacing="0" border="0" class="display table table-striped  table-bordered small-font"  id="gridAlerts"> 
            <thead>
                <tr>
                    <th>
                        Description 
                    </th>
                    <th>
                        Active?
                    </th>
                    <th>
                        Type
                    </th>
                </tr>

         <% TempData["accountAlerts"] = accountAlerts; %>                                                             
         <% foreach (var alert in accountAlerts)
            {    
         %>
     <%--<table cellpadding="0" cellspacing="0" border="0" class="display table table-striped table-bordered small-font" >--%>
<%--<table>--%>
<tr>
                      <td>
                            <%= alert.Description %>
                     </td>
            <% if (alert.Selected)
               { %>              
                     <td>
                            <input type="checkbox" value="<%= alert.AccountAlertId  %>" name="AlertSelected" checked="checked" /> 
                     </td>

                <%--<input type="checkbox" value="<%= alert.AccountAlertId  %>" name="AlertSelected" checked="checked" /> <%= alert.Description %> <br /> --%>               
            <% }
               else
               { %>

     <%--             <td>
                            <%= alert.Description %>
                     </td>--%>
                     <td>
                           <input type="checkbox"  value="<%= alert.AccountAlertId  %>" name="AlertSelected"/> 
                     </td>

              <%-- <input type="checkbox"  value="<%= alert.AccountAlertId  %>" name="AlertSelected"/> <%= alert.Description %> <br />--%>
            <% } %>
            <td>
            alert.AlertTypeId            
            </td>

        <% } %>     
  </tr>
</thead>
</table>                                                                                                                                                                         
    <div class="modal-footer"> 
    <input type="hidden" value="<%= ViewContext.RouteData.Values["controller"] %>" name="locationController" /> 
    <input type="hidden" value="<%= ViewContext.RouteData.Values["action"] %>" name="locationAction" />    
    <a href="#" class="btn btn-primary" onclick="return AccountAlertsInsertUpdate()">Add</a>    
    <a href="#" class="btn btn-primary" onclick="return SetAlerts();">Save Changes</a>
    </div>

【问题讨论】:

  • 请尽量减少重现问题的最小代码。
  • 你好,我只是把我想要作为参数的 BOLD 输入并从 javascript 传递。
  • JK - 出于任何原因,我试图大喊大叫,即使我在寻求帮助。

标签: javascript asp.net-mvc


【解决方案1】:
InputExtensions.Hidden(HtmlHelper, "accountId", ((MediaSuite.Web.UI.Code.CurrentUser)Session["current_user"]).AccountId)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-12-15
    • 2011-02-12
    • 1970-01-01
    • 2013-09-05
    • 2018-07-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多