@ Html.actionlink无法正常工作 [英] @Html.actionlink not working
问题描述
在Razor视图中......
< body>
< div style =width:500px>
@ Html.ActionLink(取消,索引,客户)
< / div>
@ *< form action =〜/ Controllers / ClientController / SaveRecord> * @
@using(Html.BeginForm(SaveNewClient,Client,FormMethod.Get))
{
。
。
。
索引是行动
ClientController是控制器
在结果视图中可以看到取消,但没有相关的链接。此链接也适用于Chrome中的开发人员控制台。
奇怪,是吧?
我的尝试:
我试过......
将@ Html.ActionLink放在BeginForm块中。
删除正文< >块。
删除助手所在的
删除BeginForm
删除尸体
去掉我满头的头发。
怎么说呢,你们这一切?
我不知道这是否构成解决方案,但它可能对其他人有所帮助。
我将问题追溯到div.wrapper css部分,从我在Interwebs上找到的侧导航解决方案获得...
div.wrapper {
保证金:140px auto;
border-radius:5px;
宽度:200px;
height:auto;
float:left;
position:fixed;
left:0;
}
如果我对此发表评论,@ Html.ActionLink()工作正常,但当然,navbard没有。
因此,我解决了根据需要将表单主体的actionlink OUTSIDE放在其所在的位置。
确保div不应与锚标记重叠。并确保你在ClientController中添加了Index方法作为Get方法。
在body标签之后加上这个。然后再试一次
@ Html.ActionLink(取消,索引,客户)
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
removing the BeginForm
removing the body
removing fist-fulls of my hair.
What say, you all?
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.
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")
这篇关于@ Html.actionlink无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!