1
How to get the new input value of a textbox
by clicking the ? button update
that would go to the bank.
1
How to get the new input value of a textbox
by clicking the ? button update
that would go to the bank.
2
The correct way to do this is through a <form>
. Using MVC and Razor, it is used as follows:
@model MeuProjeto.Models.MeuModel
@using (Html.BeginForm())
{
@Html.TextBoxFor(model => model.MeuCampo)
<button type="submit">Enviar</button>
}
Obviously, this only makes sense if you have one Model thus defined:
namespace MeuProjeto.Models
{
public class MeuModel
{
public String MeuCampo { get; set; }
}
}
The Controller you will receive the form data as follows:
[HttpPost]
public ActionResult MinhaAction(MeuModel model)
{
// O valor do campo em tela vai estar preenchido em
// model.MeuCampo
}
UPVOTE - Simplest impossible. Available new answers.
Browser other questions tagged asp.net-mvc
You are not signed in. Login or sign up in order to post.
Essentially you will send the value to the server, maybe via AJAX, and there the controller will be prepared to Learn from this. You need to give more information about what you are doing and the desired result.
– Maniero
@It’s a simple thing, I just need to get the value of a textbox. Type in webforms: string test = txtSomething.Text; Can you give me an example of this in mvc ?
– AndreeH
I’ll give you some advice as a professional: if you keep looking at MVC as Web Forms, you’ll always have difficulty and always use things the wrong way. I’ll answer anyway, but I’m almost done helping you.
– Leonel Sanches da Silva
@Ciganomorrisonmendez Put sorry there bro, I don’t know mvc, I know a little bit of web Forms, so I have these doubts and ask here. But cool.
– AndreeH