Answered by:
Create a Simple Button in MVC Razor View

Question
-
I have been having allot of trouble getting a button to do anything in my view page (razor layout) MVC design. Although I would like to pass some data as well at the moment I am trying to perform a simple page change to confirm it is working.
My View1.cshtml contains:
@using (Html.BeginForm()) { <input type="button" name="button" class="button1" value="Insert" /> }
My controller1 class contains:
[AcceptVerbs(HttpVerbs.Post)] public ActionResult MyAction(string button) { return View("TestView"); }
The controller renders my view1 page fine and there is a button there. But clicking it does not trigger my controller action and render the TestView.cshtml view. How do I do this?
- Moved by Eyal Solnik Tuesday, July 22, 2014 4:42 AM Irrelevant to C#
Tuesday, July 22, 2014 4:16 AM
Answers
All replies
-
Tuesday, July 22, 2014 4:42 AM
-
How do I move my question to that forum area?Tuesday, July 22, 2014 5:13 AM
-
It's not part of these forums; otherwise, I'd move it there.
You have to post your question again at the ASP.NET forums.
Regards, Eyal Shilony
Tuesday, July 22, 2014 5:24 AM -
Hello,
There is a specific ASP.Net MVC forum on forums.asp.net.
Karl
When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer.
My Blog: Unlock PowerShell
My Book: Windows PowerShell 2.0 Bible
My E-mail: -join ('6F6C646B61726C406F75746C6F6F6B2E636F6D'-split'(?<=\G.{2})'|%{if($_){[char][int]"0x$_"}})Tuesday, July 22, 2014 10:43 PM