0
I need to add to my template in T4 the value of action and of controller, but I can’t understand how I can pass their names.
Following example:
CREATE.cs.T4
@using (Html.BeginForm("Create", "RamoAtividades", FormMethod.post, new {@class = "form-horizontal"}))
{
@Html.AntiForgeryToken()
<div class="form-body">
Where reference "Create" and "Ramoativities", would need to automatically come the values.
How can I do that?
I tried to put the
null
but when I automatically generated thecontroller
and theviews
, the values continued asnull
in myviews.
– Aprendiz
I mean it worked tested here and was, I just did not understand how it works to be null the algorithm understand to which controller it has to send the data. Could you explain? Thank you
– Aprendiz
Every request you make in the application is mapped by httpContext, so you have stored the controller name and called action. In Htmlhelper when calling Beginform it requires some as controller and action when passing these two null parameters Htmlhelper understands that the form to be compiled has no controller and action and automatically takes these values from the request.
– AL_Mauricio
Show thanks so much for the explanation. Thanks for the help
– Aprendiz