Devexpress复选框不起作用

时间:2018-08-24 07:19:02

标签: asp.net vb.net devexpress

我的意图是首先将msform设置为visible = false,然后当我单击复选框时出现msform,但是问题是当我单击复选框时msform不会出现。代码如下:

ASP.net

<dx:ASPxPopupControl ID="popup" ClientInstanceName="popup" HeaderText="Detail" AllowDragging="true" ShowOnPageLoad="false" PopupHorizontalAlign="WindowCenter" PopupVerticalAlign="WindowCenter" runat="server" Width="60%" Height="60%">

  <dx:ASPxCheckBox ID="mschkbox" runat="server" Text="Minesweeper?" Width="330px" OnCheckedChanged="mschkbox_CheckedChanged1" ClientIDMode="Static"></dx:ASPxCheckBox>


                  <dx:ASPxFormLayout ID="MsForm" Visible="False" runat="server" ClientIDMode="static">
                    <Items>

                    <dx:LayoutItem Caption="MS Product">
                        <LayoutItemNestedControlCollection>
                            <dx:LayoutItemNestedControlContainer>
                                <dx:ASPxTextBox ID="msproductbox" runat="server" Width="100%" CssClass="maxWidth"> 
                                    <ValidationSettings Display="Dynamic" RequiredField-IsRequired="true" ErrorDisplayMode="Text" SetFocusOnError="true" ErrorTextPosition="Bottom" ErrorFrameStyle-Wrap="true"/>
                                </dx:ASPxTextBox>
                            </dx:LayoutItemNestedControlContainer>
                        </LayoutItemNestedControlCollection>
                    </dx:LayoutItem>

                   <dx:LayoutItem Caption="MS 1st Pilot Lot ID">
                        <LayoutItemNestedControlCollection>
                            <dx:LayoutItemNestedControlContainer>
                                <dx:ASPxTextBox ID="mslotidbox" runat="server"  Width="100%" CssClass="maxWidth"> 
                                    <ValidationSettings Display="Dynamic" RequiredField-IsRequired="true" ErrorDisplayMode="Text" SetFocusOnError="true" ErrorTextPosition="Bottom" ErrorFrameStyle-Wrap="true"/>
                                </dx:ASPxTextBox>
                            </dx:LayoutItemNestedControlContainer>
                        </LayoutItemNestedControlCollection>
                    </dx:LayoutItem>
</dx:ASPxFormLayout>

</dx:ASPxPopupControl>

vb.net

Protected Sub mschkbox_CheckedChanged1(sender As Object, e As EventArgs)

        If (mschkbox.Checked = True) Then
            MsForm.Visible = True
        Else
            MsForm.Visible = False
        End If

    End Sub

1 个答案:

答案 0 :(得分:1)

为了在后台代码中正确处理AutoPostBack事件,有必要将True属性设置为OnCheckedChanged

<dx:ASPxCheckBox ID="mschkbox" runat="server" AutoPostBack="True" Text="Minesweeper?" 
Width="330px" OnCheckedChanged="mschkbox_CheckedChanged1" ClientIDMode="Static">
</dx:ASPxCheckBox>

如果您将ASPxCheckBox放在ASPxGridView的{​​{1}}内,建议您阅读this issuethis,因为您正在使用{{1 }}属性。

相关问题:

ASPxCheckBox - The server-side CheckedChanged event doesn't fire in Navbar