通过javascript设置按钮属性

时间:2012-06-15 08:28:12

标签: javascript asp.net-mvc-3 devexpress

需要设置按钮的某些属性。例如“已检查”。我想这很简单,但我无法处理它。请给予和平的建议。

 Html.DevExpress().Button(
                   btnSettings =>
                   {
                       btnSettings.Name = "Details";
                       btnSettings.Text = "";
                       btnSettings.ClientSideEvents.Click = "function (s,e){Details.Checked = true}";
                       btnSettings.ControlStyle.CssClass = "button";
                       btnSettings.ToolTip = "details";
                       btnSettings.UseSubmitBehavior = false;
                       btnSettings.AllowFocus = false;
                       btnSettings.Width = 1;
                       btnSettings.Height = 1;
                   }
               )
               .Render();

1 个答案:

答案 0 :(得分:1)

来自devexpress online docu

<script type="text/javascript">
    function button1_CheckedChanged(s, e) {
        if (s.GetChecked()) {
            button2.SetEnabled(false);
            s.SetText("Enable Button");
        } else {
            button2.SetEnabled(true);
            s.SetText("Disable Button");
        }
    }
</script>

<table>
    <tr>
        <td>
            <% 
                Html.DevExpress().Button(
                    settings => {
                        settings.Name = "button1";

                        settings.Text = "Disable Button";
                        settings.Width = 120;
                        settings.GroupName = "FakeGroup";
                        settings.ClientSideEvents.CheckedChanged = "button1_CheckedChanged";
                    }
                )
                .Render();
            %>
        </td>
        <td></td>
        <td>
            <% 
                Html.DevExpress().Button(
                    settings => {
                        settings.Name = "button2";
                        settings.EnableClientSideAPI = true;
                    }
                )
                .Render();
            %>        
        </td>
    </tr>
</table>