【问题标题】:Kendo ui MVC window modal making Ajax call with paramters to controllerKendo ui MVC 窗口模型使用参数对控制器进行 Ajax 调用
【发布时间】:2013-12-20 22:39:00
【问题描述】:

我是剑道新手,我很难做到这一点。我跟着这个演示。 here 并让它完成了我希望在窗口模式中有一个文本框和一个发送按钮的部分,用户必须填写并点击发送。

我可以使用 Ajax 来调用我的控制器,但我无法在模态窗口中获取信息以通过 FormCollection 传递给控制器​​。这是我的窗口模式模板:

<script type="text/x-kendo-template" id="template">                      
<div id="details-container">  
    <h5 data-idtest="1">#= Id #</h5>                       
    <h2>#= TitleDisplay # - #= ArtistDisplay #</h2>        
    Input The Day:<input id="TheDayTextBox" name="TheDay" type="text" />

    @using (Ajax.BeginForm("TheAction", "Search", new AjaxOptions { UpdateTargetId = "#=Id" }))
    {
        <button class="btn btn-inversea" title="Log outa" type="submit">Log Offsdfsaf</button>
    }

</div>

控制器: public ActionResult TheAction(string id, FormCollection form) { …… }

那么 Kendo 是如何在 modal 中将数据传递给控制器​​的呢?

【问题讨论】:

    标签: asp.net-mvc kendo-ui asp.net-ajax


    【解决方案1】:

    尝试将您的输入放入实际表单中:

    <script type="text/x-kendo-template" id="template">                      
    <div id="details-container">  
    <h5 data-idtest="1">#= Id #</h5>                       
    <h2>#= TitleDisplay # - #= ArtistDisplay #</h2>        
    
    
    @using (Ajax.BeginForm("TheAction", "Search", new AjaxOptions { UpdateTargetId = "#=Id" }))
    {
        Input The Day:<input id="TheDayTextBox" name="TheDay" type="text" />
        <button class="btn btn-inversea" title="Log outa" type="submit">Log Offsdfsaf</button>
    }
    

    【讨论】:

    • 这个小贴士可以做到。它给了我用户输入的 TheDayTextBox 中的值。但是有没有办法让我将 Id 所在的 TheDayTextBox 中的数据和 h5 值放入 FormCollection 中?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-07
    • 1970-01-01
    • 1970-01-01
    • 2013-04-17
    相关资源
    最近更新 更多