Asp.net mvc 4 在webgrid中添加链接按钮
我想在mvc webgrid中添加一个linkbutton类,它应该调用javascript方法 我现在使用:Asp.net mvc 4 在webgrid中添加链接按钮,asp.net-mvc-4,Asp.net Mvc 4,我想在mvc webgrid中添加一个linkbutton类,它应该调用javascript方法 我现在使用: hiddenDiv.Column("",style: "col1",format: @<text> <button class="edit-book display-mode" id="@item.FacilityID"> Select</button> </text>) 但是我想用一个链接按钮来代替按钮。由于mvc中没有链接按
hiddenDiv.Column("",style: "col1",format: @<text>
<button class="edit-book display-mode" id="@item.FacilityID">
Select</button>
</text>)
但是我想用一个链接按钮来代替按钮。由于mvc中没有链接按钮,您可以通过覆盖操作链接的默认行为,使用
@Html.ActionLink
来实现
hiddenDiv.Column("",style: "col1",format: @<text>
@Html.ActionLink("Home","Index",null, new { @class="ImgAddition", @onclick="SomeScript(this);"})
</text>)
最后是你的剧本:
$('.ImgAddition').on('click', function (e) {
e.preventDefault();
$('#hiddendiv2').show();
$('#facilitygrid').hide();
var bookId = $(this).prop('id');
alert(bookId);
});
希望能有帮助
.ImgAddition{
background: url(../Images/image.gif) no-repeat top left;/* add image*/
display: block;
width: 100px;
height: 100px;
text-indent: -9999px; /* hides the link text */
}
$('.ImgAddition').on('click', function (e) {
e.preventDefault();
$('#hiddendiv2').show();
$('#facilitygrid').hide();
var bookId = $(this).prop('id');
alert(bookId);
});