2012-08-17 75 views
1

似乎无法找到涉及VB这个实现的代码,但我目前显示为超链接的动作链接:Html.ActionLink的按钮不超链接

@Html.ActionLink("Edit", "Edit", New With {.id = currentItem.CustomerId}) 

不过想显示它作为一个按钮,而不是使用twitter引导,CSS中定义的按钮看起来很棒。我知道如何正常定义按钮链接,但是如何将动作链接更改为一个?

回答

3

的CSS类属性设置为btn调用。

@Html.ActionLink("Edit", "Edit", New With {.id = currentItem.CustomerId}, New With {.class = "btn"}) 
+0

这会产生错误:“类不是整数的成员” – NickP 2012-08-17 08:32:43

+1

我不是vb.net的专家,但我认为这应该是一个 '@ Html.ActionLink(“编辑”,“编辑“,新的{.id = currentItem.CustomerId},新的{.class =”btn“})' – krolik 2012-08-17 08:35:12

+0

@krolik是的。我也不。感谢您的更正。 – Eranga 2012-08-17 08:37:55

1

你应该做一个扩展方法

public static class MVCExtensions 
    { 
public static string SubmitButton(this HtmlHelper helper, string buttonText) 
     { 
      return String.Format("<input type=\"submit\" value=\"{0}\" />", buttonText); 
     } 
} 

,那么你在代码

@Html.SubmitButton("Save")