簡體   English   中英

MVC3 HTML按鈕

[英]MVC3 HTML button

我正在使用MVC3,但我不想使用Microsoft.Web.Mvc

如何轉換此代碼以在MVC3中使用? 視圖引擎是.aspx

Html.Button ("abc", "Button abc", HtmlButtonType.Button)  

還有這個腳本

$("button[name=abc]").attr("disabled",true);  

任何反饋表示贊賞嗎?

按鈕的HTML標記

<input type="button" name="abc" disabled="true" value="Button abc" />

ASP.NET MVC 3沒有用於按鈕的內置HtmlHelper擴展方法。 你總是可以輕松地創建於:

public static class YourMvcButtonExtensionMethod
{
    public static MvcHtmlString Button(this HtmlHelper helper, string text,
                                     IDictionary<string, object> htmlAttributes)
    {
        // generate the markup for the input/button
    }
}

因此,您確實有兩種選擇:

  1. 在視圖中使用原始HTML標記
  2. 創建您的自定義擴展方法請參見上文

“我正在使用MVC3,但我不想使用Microsoft.Web.Mvc。”這聽起來令人困惑……

無論如何,您可以改用button元素。

<button disabled='true'>Button abc</button>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM