Mvc Html.ActionButton

前端 未结 7 1986
鱼传尺愫
鱼传尺愫 2020-12-16 01:52

Has anyone written one? I want it to behave like a link but look like a button. A form with a single button wont do it has I don\'t want any POST.

7条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-16 02:16

    If you want it to behave like a link but "look" like a button just use the ActionLink with a CSS Class.

    <%: Html.ActionLink("Back", "Index", null, new { @class = "link-button" })%>
    

    Here is the CSS for a Button that I am using.

    .link-button {
        -moz-border-radius:0.333em 0.333em 0.333em 0.333em;
        -moz-box-shadow:0 1px 4px rgba(0, 0, 0, 0.4);
        background:-moz-linear-gradient(center top , white, #306AB5 4%, #274976) repeat scroll 0 0 transparent;
        border-color:#306AB5 #2B5892 #274771;
        border-style:solid;
        border-width:1px;
        color:white;
        cursor:pointer;
        display:inline-block;
        font-size:1.167em;
        font-weight:bold;
        line-height:1.429em;
        padding:0.286em 1em 0.357em;
        text-shadow:0 1px 2px rgba(0, 0, 0, 0.4);
    }
    
    
    .link-button {
        color: white;
        border-color: #a1a7ae #909498 #6b7076;
        background: #9fa7b0 url(../images/old-browsers-bg/button-element-grey-bg.png) repeat-x top;
        background: -moz-linear-gradient(
            top,
            white,
            #c5cbce 5%,
            #9fa7b0
        );
        background: -webkit-gradient(
            linear,
            left top, left bottom,
            from(white),
            to(#9fa7b0),
            color-stop(0.05, #c5cbce)
        );
        -moz-text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
        -webkit-text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
        text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
        -moz-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
        -webkit-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
        }
        .link-button:hover {
            border-color: #a1a7b0 #939798 #6e7275;
            background: #b1b5ba url(../images/old-browsers-bg/button-element-grey-hover-bg.png) repeat-x top;
            background: -moz-linear-gradient(
                top,
                white,
                #d6dadc 4%,
                #b1b5ba
            );
            background: -webkit-gradient(
                linear,
                left top, left bottom,
                from(white),
                to(#b1b5ba),
                color-stop(0.03, #d6dadc)
            );
        }
        .link-button:active {
            border-color: #666666 #ffffff #ffffff #979898;
            background: #ffffdffffd url(../images/old-browsers-bg/button-element-grey-active-bg.png) repeat-x top;
            background: -moz-linear-gradient(
                top,
                #f1f1f1,
                #ffffdffffd
            );
            background: -webkit-gradient(
                linear,
                left top, left bottom,
                from(#f1f1f1),
                to(#ffffdffffd)
            );
        }
    

提交回复
热议问题