0
我的頁面有一個嚮導控件,此嚮導中有幾個控件。我有一個單選按鈕列表和兩個列表項目(是的&否)。此單選按鈕列表已將Autopost設置爲true。原因是,點擊是按鈕後,會顯示一個面板,該面板上有很多控件。點擊否,面板變得不可見。驗證和自動回送
所以問題是,當我點擊是按鈕面板顯示,如果我然後單擊向導控件的下一個按鈕,然後顯示驗證摘要說要選擇顯示面板中的數據。但是如果我點擊無單選按鈕,驗證總結仍然出現,並且回發不會發生。如果我嘗試兩次單擊「否」按鈕(即單擊「是」,然後再次單擊「否」),則發生回發並且Panel變爲不可見。
請找到下面的代碼:
<asp:Label runat="server" ID="lblCompDetails" Text=""></asp:Label>
<asp:RadioButtonList runat="server" ID="rblLaptopPC" RepeatDirection="Horizontal" AutoPostBack="true" OnSelectedIndexChanged="rblLaptopPC_CheckedChanged" CssClass="ListStyle">
<asp:ListItem Value="0" Text="Yes"></asp:ListItem>
<asp:ListItem Value="1" Text="No"></asp:ListItem>
</asp:RadioButtonList>
<asp:RequiredFieldValidator ID="rblLaptopPCValidator" ControlToValidate="rblLaptopPC" Display="Dynamic" ValidationGroup="Required" runat="server" ForeColor="Red" InitialValue="" ToolTip="" ErrorMessage="" Text="*" SetFocusOnError="True"> * </asp:RequiredFieldValidator>
<asp:Panel ID="YesPanel" runat="server" Visible="false" >
<p>
<asp:Label runat="server" ID="lblCompOwner" Text=" AssociatedControlID="rblCompOwner" ></asp:Label>
<asp:RadioButtonList runat="server" ID="rblCompOwner" RepeatDirection="Horizontal" CssClass="ListStyle">
<asp:ListItem Value="0" Text="Own Computer"></asp:ListItem>
<asp:ListItem Value="1" Text="Owned by Local Authority"></asp:ListItem>
<asp:ListItem Value="2" Text="Other"></asp:ListItem>
</asp:RadioButtonList>
<asp:RequiredFieldValidator ID="CompOwnerValidator" ControlToValidate="rblCompOwner" Display="Dynamic" ValidationGroup="Required" runat="server" ForeColor="Red" InitialValue="" ToolTip="" ErrorMessage="" Text="*" SetFocusOnError="True"> * </asp:RequiredFieldValidator>
</p>
<br />
<p>
<asp:Label runat="server" ID="lblLaptopPC" Text=" "></asp:Label>
<asp:RadioButtonList runat="server" ID="LaptopPC" RepeatDirection="Horizontal" CssClass="ListStyle">
<asp:ListItem Value="0" Text="Laptop"></asp:ListItem>
<asp:ListItem Value="1" Text="PC"></asp:ListItem>
</asp:RadioButtonList>
<br />
</p>
<p>
<asp:Label runat="server" ID="lblMSOffice" Text="?"></asp:Label>
<asp:Label ID="lblMSOfficeMsg" runat="server" Text"" CssClass="HighlitedTextCSS"></asp:Label>
<asp:RadioButtonList runat="server" ID="OfficeInstalledPost16" RepeatDirection="Horizontal" CssClass="ListStyle">
<asp:ListItem Value="0" Text="Yes"></asp:ListItem>
<asp:ListItem Value="1" Text="No"></asp:ListItem>
</asp:RadioButtonList>
<br />
</p>
<p>
<asp:Label runat="server" ID="lblCompFirewall" Text="?"></asp:Label>
<asp:RadioButtonList runat="server" ID="FirewallPost16" RepeatDirection="Horizontal" CssClass="ListStyle">
<asp:ListItem Value="0" Text="Yes"></asp:ListItem>
<asp:ListItem Value="1" Text="No"></asp:ListItem>
</asp:RadioButtonList>
<br />
</p>
<p>
<asp:Label runat="server" ID="lblCompAdminRights" Text=" "></asp:Label>
<asp:RadioButtonList runat="server" ID="AdminRightsPost16" RepeatDirection="Horizontal" CssClass="ListStyle">
<asp:ListItem Value="0" Text="Yes"></asp:ListItem>
<asp:ListItem Value="1" Text="No"></asp:ListItem>
</asp:RadioButtonList>
<br />
</p>
</asp:Panel>
protected void rblLaptopPC_CheckedChanged(object sender, EventArgs e)
{
if (rblLaptopPC.SelectedItem.Text == "Yes")
{
YesPanel.Visible = true;
InternetDetailsPanel.Visible = true;
}
else if (rblLaptopPC.SelectedItem.Text == "No")
{
YesPanel.Visible = false;
InternetDetailsPanel.Visible = false;
}
}
我無法看到帶有ID = rblLaptopPC的控件以及發佈代碼中的AutoPostback屬性,再次查看並進行相應的更新。 – 2011-04-04 10:00:56