HI WELCOME TO KANSIRIS

Pass parameters to controller after button click in MVC

Leave a Comment
MVC is not compatible with ASP.NET Web Control.
We can only use HTML Control to support the flow of the MODEL - VIEW - CONTROLLER.

Your Solution :

In the View Part: 

@using (Html.BeginForm("GetValue","Home"))
{

<input id="Text1" type="text" name="txtOne"/>
<input id="Button1" type="submit" value="button" />
}


In the Controller "Home" == > Action "GetValue" .. You get the TextBox Value

[HttpPost]
       public ActionResult GetValue()
       {
           string textboxValue = Request.Form["txtOne"];
           //Code To Insert into the Database
           return View();
       }



Here [HttpPost] attribute is required because We Posting the data.. to Another View.

0 comments:

Post a Comment

Note: only a member of this blog may post a comment.