FOR INSIDE THE aspx code

carpe2

Freshman
Joined
Jan 16, 2004
Messages
42
Location
Spain
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.
 
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
}
 
Can't he do something like this :

Code:
<%
  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 ?
 
Back
Top