carpe2 Posted April 20, 2004 Posted April 20, 2004 Hi, i would like to add something like that in the html view in the aspx code, but i dont know how to do it... n=variable; for (int i=0; i<n;i++) { <asp:RadioButton id=G<%i%>Good runat="server" Text="Good" GroupName="G1" /> <asp:RadioButton id=G1Normal runat="server" Text="Normal" GroupName="G1" /> <asp:RadioButton id=G1Bad runat="server" Text="Bad" GroupName="G1" /> } I want G followeb by a number, in order to name the radiobutton with a different name to check them after this. I tried <%for (int...)%> but it doesnt work The same in G<%i%>, i would like to appear G1, G2.... I would appreciate any help... Thanks in advance. Quote Adolfo.
MorningZ Posted April 20, 2004 Posted April 20, 2004 You'll have to dynamically add the control: http://aspnet.4guysfromrolla.com/articles/081402-1.aspx Also might want to read about "working with" dynamic controls: http://aspnet.4guysfromrolla.com/articles/082102-1.aspx Quote If you make it idiot proof, they'll build a better idiot :-)
Moderators Robby Posted April 20, 2004 Moderators Posted April 20, 2004 You cannot mix server and client code, you need to do something like this... for ( int i=0;i<n;i++) { RadioButton rb = new RadioButton(); Page.Controls.add(rb) //or you can add the control to a Panel } Quote Visit...Bassic Software
Arch4ngel Posted April 20, 2004 Posted April 20, 2004 Can't he do something like this : <% for( int i = 0; i<n; i++ ) { %> <asp:RadioButton id=G<%i%>Good runat="server" Text="Good" GroupName="G1" /> <asp:RadioButton id=G1Normal runat="server" Text="Normal" GroupName="G1" /> <asp:RadioButton id=G1Bad runat="server" Text="Bad" GroupName="G1" /> <% } %> Can't we do this just like it could be done in ASP ? Quote "If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown "Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me "A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend. C# TO VB TRANSLATOR
Moderators Robby Posted April 20, 2004 Moderators Posted April 20, 2004 Thank god we cannot. Quote Visit...Bassic Software
Arch4ngel Posted April 20, 2004 Posted April 20, 2004 Okay ! Hehe. Remembered some ASP code that could do some things like this. Quote "If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown "Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me "A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend. C# TO VB TRANSLATOR
Moderators Robby Posted April 21, 2004 Moderators Posted April 21, 2004 You still can with client controls but not server controls. Quote Visit...Bassic Software
Arch4ngel Posted April 21, 2004 Posted April 21, 2004 Okayyy. Get it running in my head! Thanks again Robby! :D :p Quote "If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown "Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me "A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend. C# TO VB TRANSLATOR
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.