mr.abuasbe 1 Posted January 25, 2016 Report Share Posted January 25, 2016 (edited) hi, i have this key on the client side (asp.net) function newContent() { var a = <%=rowCounter%>; for (i = 0; i < a; i++) { document.write('<div class="col-sm-6 col-md-4">'); document.write('<div class="thumbnail">'); document.write('<img src="<%= array[0,2]%>" alt="..."/>'); document.write('<div class="caption">'); document.write('<h3 class="d-text"><%= array[0,1]%></h3>'); document.write('<p class="d-text"><%= array[0,3]%></p>'); document.write('</div>'); document.write('</div>'); document.write('</div>'); } } but to make the loop work with the variables i need to move the code to server side,so how can i use document.write() on the server side ? thanks a lot Edited January 25, 2016 by mr.abuasbe Quote Link to post Share on other sites
justsomeguy 1,135 Posted January 25, 2016 Report Share Posted January 25, 2016 Why use Javascript? Why not just use the server-side language to directly write that HTML into the page? Quote Link to post Share on other sites
mr.abuasbe 1 Posted January 25, 2016 Author Report Share Posted January 25, 2016 Thats it, i want to make it from server side, but i didn't really know how should i make it to write to the client side. I need to replace document.write with? Quote Link to post Share on other sites
justsomeguy 1,135 Posted January 25, 2016 Report Share Posted January 25, 2016 You're already using "<%=" to write to the client. You can also use Response.Write. https://msdn.microsoft.com/en-us/library/1463ysyw(v=vs.110).aspx Quote Link to post Share on other sites
mr.abuasbe 1 Posted January 26, 2016 Author Report Share Posted January 26, 2016 thanks for your help .. now response didn't work for me .. i used this way : i created div (rowdg) and wrote in the div from the server side for (int i = 0; i < rowCounter; i++) { rowdg.InnerHtml += "<div class="+'"'+ "col-sm-6 col-md-4" +'"'+ ">"; rowdg.InnerHtml += "<div class=" + '"' + "thumbnail" + '"'+ "style="+'"'+ "height:400px" + '"'+ ">"; rowdg.InnerHtml += "<img src=" + '"' + array[i, 2] + '"' + "height="+'"'+"225"+'"'+"width="+'"'+ "225" +'"' + "/>"; rowdg.InnerHtml += "<div class=" + '"' + "caption" + '"' + ">"; rowdg.InnerHtml += "<h3 class=" + '"' + "d-text" + '"' + ">" + array[i, 1] + "</h3>"; rowdg.InnerHtml += "<p class=" + '"' + "d-text" + '"' + ">" + array[i, 3] + "</p>"; rowdg.InnerHtml += "<p class=" + '"' + "=text-center" + '"' + "><a href = " + '"' + array[i; rowdg.InnerHtml += "</div>"; rowdg.InnerHtml += "</div>"; rowdg.InnerHtml += "</div>"; } Quote Link to post Share on other sites
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.