Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
68
rated 0 times [  74] [ 6]  / answers: 1 / hits: 25970  / 7 Years ago, wed, november 15, 2017, 12:00:00

In my webapplication I am trying to add home button in all the sub pages which on clicking will trigger ActionResult Index()
Any suggestions?



I have simply added a button in my Sub page DetailsForm. Which is next to the submit button. After user is done saving user can click on home button to directly got to the Index.cshtml. Avoiding any Browser back button.
Below code definitely doesn't work for me!



  <input type=button class=btn btn-lg btn-success onclick=location.href='index.cshtml'; value=Home />

More From » jquery

 Answers
6

In MVC, you navigate to action methods in controls, not to views so your location.href='index.cshtml' cannot work.



Use an <a> element to redirect (and style it to look like a button if that's what you want), for example



@Html.ActionLink(Home, Index, Home, null, new { @class = btn btn-lg btn-success }

[#55931] Sunday, November 12, 2017, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
monetm

Total Points: 615
Total Questions: 103
Total Answers: 119

Location: Finland
Member since Fri, Oct 21, 2022
2 Years ago
monetm questions
Fri, Feb 26, 21, 00:00, 3 Years ago
Wed, Sep 9, 20, 00:00, 4 Years ago
Sun, Jul 26, 20, 00:00, 4 Years ago
Thu, Jun 11, 20, 00:00, 4 Years ago
;