2011-06-15 159 views
0

我有:我可以使用單選按鈕列表作爲提交按鈕嗎?

<asp:RadioButtonList ID="selectedYesNoQuestionBlock7" runat="server" 
    RepeatDirection="Horizontal" OnSelectedIndexChanged="Question7GotAnswered"> 
    <asp:ListItem Text="Yes" Value="1"></asp:ListItem> 
    <asp:ListItem Text="No" Value="0"></asp:ListItem> 
</asp:RadioButtonList> 

.... 

<div id="btCreate" style="margin-left: 254px; margin-top: 10px;"> 
    <asp:Button runat="server" Text="Categorize" ID="btCategorize" /> 
</div> 

我要提交wothout按鍵,只要選擇列表項之後。這是可能的,怎麼樣?

回答

6

設置AutoPostBack="true"RadioButtonList

<asp:RadioButtonList AutoPostBack="True" ID="selectedYesNoQuestionBlock7" 
     runat="server" RepeatDirection="Horizontal" 
       OnSelectedIndexChanged="Question7GotAnswered"> 
... 
</asp:RadioButtonList> 
1

看看RadioButtonList控件公開的事件,並將您的代碼放入正確的事件處理程序中。我想你應該設置爲TrueAutoPostBack的控件。