ASP.NET MVC button not firing navigation

Multi tool use
ASP.NET MVC button not firing navigation
I am learning ASP.NET MVC newly. I am trying to setup a navigation between screen as below
HomeController.cs
public class HomeController : Controller
{
public ActionResult Welcome(string newId)
{
ViewBag.Message = "Welcome to my shop.";
return View();
}
}
Welcome.cshtml
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}
@using (Html.BeginForm())
{
<h1>The shoppee</h1>
<input type="button" title="Cart" value="Shop Items" onclick="window.location.href='@Url.Action("SelectItems", "Cart") %>'" />
}
I have built a new CartController with SelectItems.cshtml. I have added them to routeconfig.cs. But the button above is not firing at all. I am able to manually navigate to the url using
http://localhost:portnumber/Cart/SelectItems
% >
I know its going to be lame. But didn't expect it to be this lame. Thanks mate. The form is not required as it is only a redirect, it was an attempt to make it work.
– Ramki
Jul 3 at 6:06
Be far easier to use a link (
@Html.ActionLink(...)
) and style it as a button– Stephen Muecke
Jul 3 at 6:16
@Html.ActionLink(...)
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Simply remove the
% >
at the end of the url. Also, Why do you need to put that button inside a form?– Rumpelstinsk
Jul 3 at 6:03