如何在DevExpress

时间:2018-04-06 08:38:10

标签: button devexpress

我用DevExpress开发一个应用程序,但我的代码有问题,我想要一个条件为我的按钮“保存”,如果条件“A”按钮保存启用,但如果条件“B”按钮保存禁用,但在我的代码中,“保存”按钮在2种情况下启用。  如何解决这个问题?

 <%   if (Condition == A )
                                                      {
                                                 %>
                <td>

                        <dx:ASPxButton ID="BtSavelisteningScale" runat="server" HorizontalAlign="NotSet" 
                            ImagePosition="Left" Text="Enregistrer" VerticalAlign="NotSet" ClientEnabled="true" ClientInstanceName="BtSavelisteningScale"
                            Wrap="Default" AutoPostBack="false" meta:resourcekey="BtSavelisteningScaleResource1">
                            <ClientSideEvents Click="function(s, e){if (ASPxClientEdit.ValidateGroup('grpVal')) {CPlEvalScale.PerformCallback('Enregistrer');} }" />
                            <%--<ClientSideEvents Click="function(s, e){ if (ASPxClientEdit.ValidateGroup('grpVal')) {GetScore();GvLs.PerformCallback('UpdateListenningScale');}}" />--%>
                        </dx:ASPxButton>

                  </td>

                    <% } %>
                    <%   else if (Condition == B )
                                                      {

                                                 %>

                 <td>
                        <dx:ASPxButton ID="BtSavelisteningScaleFalse" runat="server" HorizontalAlign="NotSet"

                            ImagePosition="Left" Text="Enregistrer" VerticalAlign="NotSet" ClientEnabled="false" ClientInstanceName="BtSavelisteningScale"
                            Wrap="Default" AutoPostBack="false" meta:resourcekey="BtSavelisteningScaleResource1">
                            <ClientSideEvents Click="function(s, e){if (ASPxClientEdit.ValidateGroup('grpVal')) {CPlEvalScale.PerformCallback('Enregistrer');} }" />
                            <%--<ClientSideEvents Click="function(s, e){ if (ASPxClientEdit.ValidateGroup('grpVal')) {GetScore();GvLs.PerformCallback('UpdateListenningScale');}}" />--%>
                        </dx:ASPxButton>
                  </td>
                    <% } %>

1 个答案:

答案 0 :(得分:0)

默认设置Visiable = False然后 Page_Load活动或Page_Init活动检查您的情况。例如:

protected void Page_Load(object sender, EventArgs e)
    {
        if (Condition == A)
        {
            BtSavelisteningScale.Visiable = True;
            BtSavelisteningScaleFalse.Visiable = False;
        }
        else if (Condition == B)
        {
            BtSavelisteningScale.Visiable = False;
            BtSavelisteningScaleFalse.Visiable = True;
        }
    }

Protected void Page_init(object sender, EventArgs e)
        {
            if (Condition == A)
            {
                BtSavelisteningScale.Visiable = True;
                BtSavelisteningScaleFalse.Visiable = False;
            }
            else if (Condition == B)
            {
                BtSavelisteningScale.Visiable = False;
                BtSavelisteningScaleFalse.Visiable = True;
            }
        }