Send Label.textContent as parameter in an @ Url.Action

0

Hello people, I am a newbie in MVC and I have a question, is it possible to pass the text of a Label as a parameter?

My idea, is that from that btn, send the controller the text of the label and then use it in the controller. The point is, how do I get it ?, since it does not allow me to collect the value by the Id

    
asked by Ulises Gómez Bonilla 02.08.2018 в 04:44
source

1 answer

0

The way in which the View connects to the Controlles is making calls. Post or Get .. for this you need to have a form and a submit button.

Although I do not see any sense, why do you want to send something that is not modifiable? that means you assign value from code.

To send the values to the controller, we use the property name of the input.

So if you want to give an input tag look, you could do something like this: (in the View)

<input type="text" name="miTexto" value="Este es el Contenido" style="border:none;background:none;" readonly>

And then in the controller, you can access this value

 public ActionResult Index( string miTexto)
        {            
            return View();
        }
    
answered by 02.08.2018 в 07:19