我的意图是首先将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
答案 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 issue和this,因为您正在使用{{1 }}属性。
相关问题:
ASPxCheckBox - The server-side CheckedChanged event doesn't fire in Navbar