我创建了一个 aspx 页面,我希望在其中根据用户选择启用一些控件。
如果用户选择All
两个单选按钮应启用,否则隐藏。
我的声明部分是:
<tr>
<td>
<asp:Label ID="lblCommunityMembers" runat="server" Text="Community Members" />
</td>
<td>
<asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server">
</asp:ScriptManagerProxy>
<asp:UpdatePanel ID="upCommunityMembers" runat="server">
<ContentTemplate>
<asp:RadioButton ID="rdbCommunityMembersAll" runat="server" Text="All" GroupName="grpCommMembers" Checked="true" OnCheckedChanged="rdbCommunityMembersAll_CheckedChanged" AutoPostBack="true" />
<asp:RadioButton ID="rdbCommunityMembersSelectedUsers" runat="server" Text="Selected Users" GroupName="grpCommMembers" OnCheckedChanged="rdbCommunityMembersSelectedUsers_CheckedChanged" AutoPostBack="true" />
<SharePoint:ClientPeoplePicker ID="ppCommunityMembers" runat="server" AllowMultipleEntities="true" AllowEmpty="false" Visible="false" />
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblCommunityCatagory" runat="server" Text="Community Catagory" />
</td>
<td>
<asp:DropDownList ID="ddlCommunityCatagory" runat="server">
<asp:ListItem Value="0">---- Select One ----</asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:RequiredFieldValidator ID="rfvCommunityCatagory" runat="server" InitialValue="0" ErrorMessage="Please Select Community Catagory"
ForeColor="Red" ControlToValidate="ddlCommunityCatagory" Display="Dynamic" />
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblCommunityAccess" runat="server" Text="Required Approval?" Visible="false" />
</td>
<td>
<asp:RadioButton ID="rdbRequiredApprovalYes" runat="server" Text="Yes" GroupName="grpCommMembers" Checked="true" Visible="false" />
<asp:RadioButton ID="rdbRequiredApprovalNo" runat="server" Text="No" GroupName="grpCommMembers" Visible="false"/>
</td>
</tr>
我背后的代码:
protected void rdbCommunityMembersSelectedUsers_CheckedChanged(object sender, EventArgs e)
{
if (rdbCommunityMembersSelectedUsers.Checked)
{
enableControls();
}
else
{
disableControls();
}
}
protected void rdbCommunityMembersAll_CheckedChanged(object sender, EventArgs e)
{
if (rdbCommunityMembersAll.Checked)
{
disableControls();
}
else
{
enableControls();
}
}
protected void enableControls()
{
ppCommunityMembers.Visible = true;
lblCommunityAccess.Visible = true;
rdbRequiredApprovalNo.Visible = true;
rdbRequiredApprovalYes.Visible = true;
}
protected void disableControls()
{
ppCommunityMembers.Visible = false;
lblCommunityAccess.Visible = false;
rdbRequiredApprovalNo.Visible = false;
rdbRequiredApprovalYes.Visible = false;
}
如果社区成员被全部选中,那么“需要批准?” 部分应该被隐藏。
但问题是,当我选择选定的用户时,我只看到人员选择器控件可见,所需的批准控制没有显示。我错过了什么?