Answer the question
In order to leave comments, you need to log in
How to pass data from View to Controller?
Good afternoon! There is a view Index.cshtml, when clicking, you need to pass the list to the method in the UsersController.cs controller
@model IEnumerable<Certificates_MVC_EF_2021.Models.User>
@{Html.BeginForm("CreateDocument", "Home", FormMethod.Get);
{
<div>
<input type="submit" value="Create Document" style="width:150px;height:27px" />
</div>
}
Html.EndForm();
}
public FileResult CreateDocument()
{
//Creates an instance of WordDocument class
WordDocument document = new WordDocument();
..............................................................................
//Download Word document in the browser
return File(stream, "application/msword", "Table.docx");
}
Answer the question
In order to leave comments, you need to log in
Should I pass a list from model or some other list?
You have page content hidden under html helpers. What's inside is anyone's guess.
There is a backend which is the code that runs on the server and a front that is displayed to the client.
The controller is back.
A click is an operation in the View, which is located on the client's computer in the browser.
The interaction between these parts goes through the Internet. And here HTTP or WebSocket requests are available to you.
Here through requests and transfer the data.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question