I have Button and TextBox
in View
of ASP.NET MVC. Now, how to send some value (for example string x="1";
) of Button to TextBox after Click on this Button? I have this value showing in url address like this: /local:xxxxx/Calculator?TextBox=&Command=1
after clicked Button with value 1 but I have no idea how to send this value to TextBox and convert to int and put in some int variable. My View look like this:
<input type="text" name="TextBox" value=""/>
<table>
<tr>
<td><button type="submit" name="Command" value="7">7</button></td>
</tr>
My model look like this:
public class CModel
{
public string Command { get; set; }
public string TextBox { get; set; }
}
And Controller:
[HttpGet]
public ActionResult Index()
{
CModel model = new CModel();
return View(model);
}
[HttpPost]
public ActionResult Index(CModel model)
{
if (model.Command == "1")
{
//do this and this
}
else if(model.Command == "2")
{
//do this and this
}
else if....{}
return View(model);
}
Is there some way to get this value "1" and send to to TextBox and after that send to some variable of type int for save it? How to do that?