Elango Sengottaiyan
Elango Sengottaiyan

Reputation: 176

Client side to server side Data Passing C# MVC

Is there any alternative method to pass and call the controller method in MVC.

Normally I know,

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

or

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

And

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

Is there any alternative method is there? If there let me explain that's use and description.

Upvotes: 0

Views: 1529

Answers (2)

khalid aboubakr
khalid aboubakr

Reputation: 1

It's depending on what is the issue you are having while try to using the specific code that you have been provided Can you kindly tell us the specific problem The solution maybe easier than finding alternative ways

Upvotes: 0

TanvirArjel
TanvirArjel

Reputation: 32069

Yes! there is another one as you are expecting and that is:

@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" />
}

Upvotes: 1

Related Questions