[英]create new question if yes/no radio button selected c# asp.net
我有個問題:
<div>
Is hacking good?</div>
<div>
<asp:RadioButtonList ID="1question" runat="server"
RepeatDirection="Horizontal">
<asp:ListItem Text="Yes" Value="1"></asp:ListItem>
<asp:ListItem Text="No" Value="0"></asp:ListItem>
</asp:RadioButtonList>
</div>
如果選擇是/否,我想動態添加新問題。
如果是/否|| 1/0選擇,我正在調用方法GetQuestion(int questionId)..此方法返回下一個問題的文本。 接下來應該動態創建此問題(javascript)。 如何動態創建它?
我怎樣才能做到這一點?
首先,新問題可以在那里准備就緒但可以隱藏起來,或者可以即時創建。
可以說存在但隱藏。
<asp:Panel id="pnlSecondQuestion" runat="server" Visible="false"
EnableViewState="false">
<div>Is hacking ethical?</div>
<asp:RadioButtonList ID="SecondQuestion" runat="server"
RepeatDirection="Horizontal">
<asp:ListItem Text="Yes" Value="1"></asp:ListItem>
<asp:ListItem Text="No" Value="0"></asp:ListItem>
</asp:RadioButtonList>
</asp:Panel>
現在可以隱藏html部分並使用javascript打開它,或者完全隱藏並使用背后的代碼打開它。
Visible="false"
則在單擊第一個問題時進行自動回發,只需打開一個pnlSecondQuestion.Visible=true
在這種情況下,為避免刷新整個頁面,可以使用UpdatePanel扭曲所有問題。 style="display:none"
將其隱藏,那么您將創建一個javasript函數,當用戶單擊第一個問題onclick="return makeitvisible()"
時,該函數將使其可見 現在,如果您要即時提出完整的問題,則可以使用PlaceHolder,然后在后面的代碼中動態創建問題,但這有點困難。
希望能有所幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.