2012-11-07 57 views
0

我有一個RadioButtonListTextBox。按照RadioButtonList選擇,我想填充文本框。文本框濾波根據單選按鈕選擇

<asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged"> 
     <asp:ListItem Text="NUMBER" Value="1" Selected="True"></asp:ListItem> 
     <asp:ListItem Text="TEXT" Value="2"></asp:ListItem> 
</asp:RadioButtonList> 

<asp:TextBox ID="txtID" runat="server"> 

當我點擊列表項與價值1,用戶可以輸入數字到文本框。值爲2,數字+文字。 我也想設置的長度。有人可以告訴我如何做到這一點?

+0

我不想使用Ajax控件工具包 – ozkank

+0

目前尚不清楚你已經嘗試你想要什麼或獲得選擇的值。您是否想根據'RadioButtonList'中的選擇在JavaScript中過濾該文本框? –

+0

是的,我想改變在JavaScript文本框的過濾器類型。一個選項,它將是數字文本框。 – ozkank

回答

0

編寫一個Javascript函數,可從RadioButtonList1控件中獲取選定值,並與值12比較。如果是1,應允許用戶只輸入數字。這可以從文本框的客戶端的按鍵事件,這將檢查比較的結果,允許按鍵實際在文本框中呈現強制執行。

參考this來看看如何從RadioButtonList控制使用Javascript

相關問題