Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
in a Razor view...
<body>
<div style="width:500px">
@Html.ActionLink("Cancel", "Index", "Client")
</div>
@*<form action="~/Controllers/ClientController/SaveRecord">*@
@using (Html.BeginForm("SaveNewClient", "Client", FormMethod.Get))

{
.
.
.
Index is action
ClientController is controller

"cancel" is seen on the resulting view but there is no associated link. Also the link works in the developer console thingy in Chrome.

Odd, huh?

What I have tried:

I have tried ...
putting @Html.ActionLink inside the BeginForm block.
removing the body<> block.
removing the
blok that the helper is inside of.
removing the BeginForm
removing the body
removing fist-fulls of my hair.

What say, you all?
Posted
Updated 28-Aug-18 7:28am
Comments
ZurdoDev 24-Aug-18 13:06pm    
What do you mean by "not working?"
Member 13944054 24-Aug-18 13:18pm    
2018,

By "not working" I mean that in the browser the link is rendered simply as text with no action - does not take the browser anywhere when you click. However I notice that in the developer tools in Chrome the link works.

I just now traced the problem to a home-grown site.css file and am attempting to isolate the cause.
Member 13944054 24-Aug-18 17:56pm    
SO,

I narrowed it down to a home-grown site.css but I cannot, for the life of me, figure out what in the following is breaking my link...





/* Set padding to keep content from hitting the edges */
.body-content {
padding-left: 25px;
padding-right: 5px;
align-content: space-around;

}


h1 {
/*border-bottom: 5px solid ;*/
font: 2.75em/1.75em Georgia, serif;
color:darkred
}

h2{
border-bottom: 2px solid;
font: 2.00em/1/50em Georgia, serif;
color:brown
}

h3{
font:200;
color:burlywood
}

h4{
font:100;
color:burlywood
}

ul {
list-style-type: none;
}

headerfont{
font: 24px;
color: blue
}

body {
margin: 0px;
padding: 1em, 1em;
margin-left: 50PX;
background-color: #ffffff;
font: 75%/2.75em "Trebuchet MS", Verdana, sans-serif;
color: brown;
align-content: center;
/*background-image:url("../Images/7FWoodBackground1024x768.jpg");*/
}

.main {
padding: 16px;
margin-top: 30px;
/*height: 1500px;*/
}

/*.navbar {
overflow: hidden;
background-color: #ffffff;
color: black;
position: fixed;
top: 0;
width: 100%;
border-bottom: 10px solid #eeeeee;
}

.navbar a {
float: left;
display: block;
color: black;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
/*border-bottom: 10px solid #eeeeee;
}

.navbar a:hover {
background: #ddd;
color: black;
}*/

*{
margin: 0;
padding: 0;
outline: none;
/*border-radius: 5px;*/

-webkit-box-sizing: border-box;
/*-webkit-border-radius:10px;*/

-moz-box-sizing: border-box;
box-sizing: border-box;
}

/*body {
background: #eee;
color: #444;
-webkit-font-smoothing: antialiased;
font-family: 'Helvetica Neue', sans-serif;
font-size: 20px;
font-weight: 400;
height: auto !important;
height: 50%;
min-height: 50%;
text-rendering: optimizeLegibility;
}*/


div.wrapper {
margin: 140px auto;
border-radius: 5px;
width: 200px;
height: auto;
/*float: left;*/
position:fixed;
left:0;
}


p {
font-family: georgia;
font-size: 1.5em;
border-width:1.0em;
border-color:aqua;
border-bottom-style:solid;
line-height: 25px;
margin: 24px 0;
text-align: center;
}

nav.virticle {
border-radius:4px;
box-shadow: 0 0 10px rgba(0,0,0,.15);
border-collapse:separate;
overflow: hidden;
text-align: center;
perspective: 1px;
/*position:fixed;
left:0;*/
}
nav.virticle > ul {
list-style-type: none;
}
nav.virticle > ul > li {
display: inline-block ;
}

nav.vertical > ul > li > a {
background-color: rgb(157, 34, 60);
background-image: -webkit-linear-gradient(135deg, rgb(114, 51, 98), rgb(157, 34, 60));
background-image: -moz-linear-gradient(135deg, rgb(114, 51, 98), rgb(157, 34, 60));
background-image: -o-linear-gradient(135deg, rgb(114, 51, 98), rgb(157, 34, 60));
background-image: linear-gradient(135deg, rgb(114, 51, 98), rgb(157, 34, 60));
border-bottom: 1px solid rgba(255,255,255,.1);
border-left: 10px solid brown;
box-shadow: inset 0 1px 1px rgba(0,0,0,.1), 0 1px 1px rgba(0,0,0,.1);
color: rgb(255,255,255);
display: block;
font-size: .85rem;
font-weight: 500;
height: 50px;
letter-spacing: .5rem;
line-height: 50px;
text-shadow: 0 1px 1px rgba(0,0,0,.1);
text-transform: uppercase;
transition: all .1s ease;
text-decoration: none;
padding: 0 0 0 5px;
}

nav.vertical > ul > li > a:hover {
background-color: rgb(114, 51, 98);
background-image: -webkit-linear-gradient(150deg, rgb(114, 51, 98), rgb(114, 51, 98));
background-image: -moz-linear-gradient(150deg, rgb(114, 51, 98), rgb(114, 51, 98));
background-image: -o-linear-gradient(150deg, rgb(114, 51, 98), rgb(114, 51, 98));
background-im

I don't know if this constitutes a solution but it may help others.

I traced the problem to a div.wrapper css section, obtained from a side-navbar solution I found on the Interwebs...
div.wrapper {
margin: 140px auto;
border-radius: 5px;
width: 200px;
height: auto;
float: left;
position:fixed;
left:0;
}

If I comment this out the @Html.ActionLink() works fine but, of course, the navbard does not.

So, I resolved simply put the actionlink OUTSIDE of the form body where it behaves as needed.
 
Share this answer
 
Comments
Richard Deeming 28-Aug-18 12:29pm    
Sounds like an invisible part of your wrapper element is overlapping the link, which would prevent you from clicking on it. Try using the dev tools "element picker" to click the link - you'll probably see that it selects your wrapper element instead.
make sure that div should not overlap the anchor tag. and make sure you have added Index method in ClientController as Get method.


add this, just after the body tag. and try again

@Html.ActionLink("Cancel", "Index", "Client")
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900