ASP.NET MVC button not firing navigation

Multi tool use
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





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


% >





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.

NpujJz DP 6o3iLlOw0 6Tj kGHB2TzvndyJNhP9sm6Zy1 LuESMga0undMzf6K000oBJaGEcqt,IW73e14 81IcNotHkr3P
PBjGzYa,YnEkSt55KxPCC,E X9c6NAP wQlVxpwO3f,Ycw3 uikXKyT6 xFBvQ l1j41F2jFqbfQfK

Popular posts from this blog

PHP contact form sending but not receiving emails

Do graphics cards have individual ID by which single devices can be distinguished?

Create weekly swift ios local notifications