T
tshad
I am trying to find the best way to set up RadioButtons, CheckBoxes, and
textboxes on the fly.
What I am doing is putting on a page questions and answers that the user has
defined in his file. The answers can be RadioButtons, CheckBoxes or a
TextBox. It can only one type. For example, you could have up to 5 Radio
buttons or up to 5 CheckBoxes or 1 TextBox. But you can't mix an match.
What I did at the moment is create all the possible choices and make them
invisible. I will only make the ones I need visible - based on the users
choice for that particular question:
<asp:Label ID="Question1" visible="false" runat="server"/>
<asp:RadioButton "RadioButton11" Visible="false" Group"Question1"
runat"server"/><asp:RadioButton "RadioButton12" Group"Question1"
runat"server"/><asp:RadioButton "RadioButton13" Group"Question1"
runat"server"/><asp:RadioButton "RadioButton14" Group"Question1"
runat"server"/><asp:RadioButton "RadioButton15" Group"Question1"
runat"server"/>
<asp:RadioButton "CheckBox11" Visible="false"
runat"server"/><asp:RadioButton "RadioButton12"
runat"server"/><asp:RadioButton "RadioButton13"
runat"server"/><asp:RadioButton "RadioButton14"
runat"server"/><asp:RadioButton "RadioButton15" runat"server"/>
<asp:TextBox "TextBox1" runat="server"/>
The other way would be to set up only 5 objects for each question:
<asp:Label ID="Question1" visible="false" runat="server"/>
<asp:RadioButton "RadioButton11" Visible="false" Group"Question1"
runat"server"/><asp:RadioButton "RadioButton12" Group"Question1"
runat"server"/><asp:RadioButton "RadioButton13" Group"Question1"
runat"server"/><asp:RadioButton "RadioButton14" Group"Question1"
runat"server"/><asp:RadioButton "RadioButton15" Group"Question1"
runat"server"/>
This only works if you can change the asp object type (which I don't think
you can).
The other way was to dynamically create the objects. Not sure how to do
this or if you can. You can as part of a Datagrid (I believe), but what
about as just an object on a page?
Is there a better way than the way I am doing it?
Thanks,
Tom
textboxes on the fly.
What I am doing is putting on a page questions and answers that the user has
defined in his file. The answers can be RadioButtons, CheckBoxes or a
TextBox. It can only one type. For example, you could have up to 5 Radio
buttons or up to 5 CheckBoxes or 1 TextBox. But you can't mix an match.
What I did at the moment is create all the possible choices and make them
invisible. I will only make the ones I need visible - based on the users
choice for that particular question:
<asp:Label ID="Question1" visible="false" runat="server"/>
<asp:RadioButton "RadioButton11" Visible="false" Group"Question1"
runat"server"/><asp:RadioButton "RadioButton12" Group"Question1"
runat"server"/><asp:RadioButton "RadioButton13" Group"Question1"
runat"server"/><asp:RadioButton "RadioButton14" Group"Question1"
runat"server"/><asp:RadioButton "RadioButton15" Group"Question1"
runat"server"/>
<asp:RadioButton "CheckBox11" Visible="false"
runat"server"/><asp:RadioButton "RadioButton12"
runat"server"/><asp:RadioButton "RadioButton13"
runat"server"/><asp:RadioButton "RadioButton14"
runat"server"/><asp:RadioButton "RadioButton15" runat"server"/>
<asp:TextBox "TextBox1" runat="server"/>
The other way would be to set up only 5 objects for each question:
<asp:Label ID="Question1" visible="false" runat="server"/>
<asp:RadioButton "RadioButton11" Visible="false" Group"Question1"
runat"server"/><asp:RadioButton "RadioButton12" Group"Question1"
runat"server"/><asp:RadioButton "RadioButton13" Group"Question1"
runat"server"/><asp:RadioButton "RadioButton14" Group"Question1"
runat"server"/><asp:RadioButton "RadioButton15" Group"Question1"
runat"server"/>
This only works if you can change the asp object type (which I don't think
you can).
The other way was to dynamically create the objects. Not sure how to do
this or if you can. You can as part of a Datagrid (I believe), but what
about as just an object on a page?
Is there a better way than the way I am doing it?
Thanks,
Tom