Link to home
Start Free TrialLog in
Avatar of Mohammad Alsolaiman
Mohammad AlsolaimanFlag for Saudi Arabia

asked on

How come JS parameters passed from MVC view to controller in this scenario?

I had found code and its work perfect, but
I need to know how the parameters passed from the view javascript (function LoadDataTable()) to the actionResult (GetSalesData(SalesRequestModel request)).
Where I can't see physical association between those two functions?
Only I need someone to describe this scenario to me Please.
Please see attached files:

User generated imageUser generated imageUser generated imageIndexSales.cs.txtEmployeeController.cs.txtSalesDataModel.cs.txt
Avatar of David H.H.Lee
David H.H.Lee
Flag of Malaysia image

Perhaps you can understand better after you read this article below.

Action Result In ASP.NET MVC

Avatar of Mohammad Alsolaiman


Thank you David H H. Lee
First: thanks to for the very helpful article.
Please correct me if I’m wrong  
In this part of the essay
This derive type is used for returning the javascript code from the controller. When it executes we see the javascript code as we mentioned in the controller’s action method. For details, let’s take an example,

  1. public JavaScriptResult Index()  
  2. {  
  3.     return JavaScript("alert('Zain Ul hassan')");  
  4. }  
And the View named as Index has following code,
  1. <script type="text/javascript" src="@Url.Action("Index")"></script>  
The output is as shown below,
User generated image

What I had understood. In my project I have js function in the view with the name “LoadDataTable”
Contains this line
“url”: “Url.Action(“GetSalesData”,”Employee”)”’
And then we define the parameters beneath
so the url is pointing to our action result method and passing the parameters to this particular Action method
Is that true my friend?
Again thanks for the helpful article  

The part of the article I mean is


Avatar of Kelvin McDaniel
Kelvin McDaniel
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks to all of you