2012-01-04 62 views
2
<asp:RadioButton ID="rdoComm" runat="server" Text="Business Investment" AutoPostBack="true" 
     GroupName="selectionType" OnCheckedChanged="rdoComm_CheckedChanged" /> 
    <asp:RadioButton ID="rdoRes" runat="server" Text="Real Estate" GroupName="selectionType" 
     AutoPostBack="true" OnCheckedChanged="rdoRes_CheckedChanged" /> 
    <asp:RadioButton ID="rdoBoth" runat="server" Text="Both" GroupName="selectionType" 
     AutoPostBack="true" OnCheckedChanged="rdoBoth_CheckedChanged" /> 

每當我強迫驗證與「Page_ClientValidate(‘組’)」單選按鈕就不會回傳,但是如果我不使用我的方法提到並保留到asp.net驗證,即使該頁面無效單選按鈕仍然回發。asp.net單選按鈕不回發時頁面無效

單選按鈕並不意味着回發,但它們用於隱藏和顯示頁面上的控件。

有何想法?>?

回答

1

你應該轉移到一個基於JavaScript的解決方案...這將避免回傳和p ^向用戶提供更大的體驗。

但如果你不能,只要設定CausesValidation propertyfalse的單選按鈕:

<asp:RadioButton ID="rdoComm" runat="server" Text="Business Investment" AutoPostBack="true" CausesValidation="false" 
    GroupName="selectionType" OnCheckedChanged="rdoComm_CheckedChanged" /> 
<asp:RadioButton ID="rdoRes" runat="server" Text="Real Estate" GroupName="selectionType" CausesValidation="false" 
    AutoPostBack="true" OnCheckedChanged="rdoRes_CheckedChanged" /> 
<asp:RadioButton ID="rdoBoth" runat="server" Text="Both" GroupName="selectionType" 
    AutoPostBack="true" CausesValidation="false" OnCheckedChanged="rdoBoth_CheckedChanged" /> 
+0

感謝史蒂夫,的CausesValidation不會因爲在我的情況下,頁面的驗證工作已經觸發,頁面不有效。我試過jQuery的顯示和隱藏,但問題是驗證仍然會觸發,即使該控件是隱藏的。 – nolimit 2012-01-04 00:14:51

+0

我只是照顧了頁面上的驗證切換,並做了一個JavaScript來完成這項工作,關閉了自動回發功能並且它工作。 – nolimit 2012-01-04 01:33:01