代码之家  ›  专栏  ›  技术社区  ›  Elango Sengottaiyan

客户端到服务器端的数据传递C MVC

  •  0
  • Elango Sengottaiyan  · 技术社区  · 7 年前

    在MVC中是否有其他方法可以传递和调用控制器方法?

    通常我知道,

    @Html.Beginform('MethodName','Controller Name')
    

    或

    <form action="/{Controller Name}/{Method Name}" method="post">  
        <div>My Html Form</div>       
    </form> 
    

    和

    $.ajax({
        type: "POST",
        data: {},
        url: "../{Controller Name}/{Method Name}",
        successs: function(response) {},
        error: function(response) {}
    });
    

    有其他方法吗?如果有,让我解释一下这是用法和描述。

    2 回复  |  直到 7 年前
        1
  •  0
  •   TanvirArjel    7 年前

    对!还有一个你所期待的,那就是:

    @using (Ajax.BeginForm("MethodName", "ControllerName", new AjaxOptions {
        InsertionMode = InsertionMode.Replace, 
        UpdateTargetId = "targetReplaceId", //target div that will be replaced with the response
        LoadingElementId = "loader" // div with .gif loader - that is shown when data are loading   
    }))
    {
        // Here is your form input fields
    
        <input  type="submit" value="Submit" />
    }
    
        2
  •  0
  •   khalid aboubakr    7 年前

    这取决于您在尝试使用所提供的特定代码时遇到的问题 你能告诉我们具体的问题吗 解决方案可能比寻找替代方法更容易。

    推荐文章