Results 1 to 3 of 3

Thread: Generating code in ASP.Net using "For"

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Denmark
    Posts
    1,049

    Question Generating code in ASP.Net using "For"

    I have some code looking like this in JavaScript:
    Code:
    <script language="JavaScript"><!--
    								for (i=1;i<11;i++){
    								document.write('<tr>');
    								document.write('<td><select name="komp' +i+ '" style="WIDTH: 125px" onclick="click_komp();">');
    									document.write('<% Do While Not Rs1.EOF %>');
    									document.write('<option value="<%=rs1.fields(0).value%>"><%=rs1.fields(2).value%></option>');			
    									document.write('<%Rs1.MoveNext()%>');
    									document.write('<%Loop%>');
    								document.write('</select>');
    								document.write('</td>');
    								document.write('<td><select name="dimen' +i+ '" onclick="saet_dim' +i+ '();">');
    									document.write('<option selected value="none"> </option>');
    									document.write('</select>');
    								document.write('</td>');
    								document.write('<td><select name="serie' +i+ '" onclick="calc_serie();">');
    										document.write('<% Do While Not Rs7.EOF %>');
    										document.write('<option value="<%=rs7.fields(0).value%>"><%=rs7.fields(1).value%></option>');			
    										document.write('<%Rs7.MoveNext()%>');
    										document.write('<%Loop%>');
    									document.write('</select>');
    								document.write('</td>');
    								document.write('<td><input type="text" name="kappedim' +i+ '" class="resfelt" size="3" value="90" readonly></td>');
    								//document.write('<td><input type="text" name="prisMedie' +i+ '" class="tastfelt" size="3" value="4,54" ></td>');
    								//document.write('<td><input type="text" name="prisPeh' +i+ '" class="tastfelt" size="3" value="7,00"></td>');
    								document.write('</tr>');
    							}
    							//--></script>
    Now I'm writing an ASP.Net application which use server controls. How can I make some automated content like using "For..." in JavaScript?

  2. #2
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    Are you looking for something that does the same as Document.Write? Then it is Response.Write. But its not exactly the same as in javascript for it positioning. In javascript it begins to write whereever you put your script but its not the case in Response.Write.
    Alternativley you can use a label or literal control and place it on the form then use that "For..." to build its text porperty.
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Denmark
    Posts
    1,049
    Hi, what I wish to to is to generate 100 text fields in a table without write the code 100 times, if you understand.

    'Alternativley you can use a label or literal control and place it on the form then use that "For..." to build its text porperty.'

    Can I do that someway using this?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width